Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: fuzzywobs on June 02, 2015, 09:48:52 AM

Title: Getting the camera to focus on your player using LookAt?
Post by: fuzzywobs on June 02, 2015, 09:48:52 AM
I'm, trying to integrate LookAt in my game and have so far been unsuccessful.

In the game the character runs around and the player views him from a distance from a bunch of different fixed cameras scattered around the level in different rooms. When the character walks to a certain area/room, he triggers an event which causes the current camera to deactivate and activate the next one as to have a better view of him. So far I have achieved this. However, I want the camera that activates to be focused at on the character either at all times or at least to start off with. This is because I do not know exactly where the character is going to trigger the camera switch so it cannot be preset, I need the camera to be focused on the character.


I managed to achieve this before, but since I restarted from scratch I can no longer get it to work.

I think it hast to do with setting the characters position as a global variable and have the LookAt vector set to this position, but I cannot seem to get it working.

Any ideas?
Thanks
Title: Re: Getting the camera to focus on your player using LookAt?
Post by: fuzzywobs on June 04, 2015, 05:05:31 AM
Bump.

Anyone? I feel this should be a really simple solution!
Title: Re: Getting the camera to focus on your player using LookAt?
Post by: NinjaX on June 06, 2015, 03:13:47 PM
Do you use global variables ?

Like: Your character would have a "Get Owner" on it, and you create a Global var that is a "Gameobject" and call it mike or whatever :D

And than tell the camera to loot at MIKE :D
Title: Re: Getting the camera to focus on your player using LookAt?
Post by: fuzzywobs on June 08, 2015, 08:35:59 AM
I managed to get the desired effect before I just cant replicate it anymore (I must have gotten lucky). When I did get it I did use global variables.

I'm just a bit confused as to how to set it up. I tried storing the characters position and location as a global variable, and have the camera LookAt these but that didnt work.

Any ideas?
Title: Re: Getting the camera to focus on your player using LookAt?
Post by: bobby1984 on June 21, 2015, 11:33:37 PM
you can create an fsm for each camera and in the action browser find the 'smooth look at' action and add this action. Then in the target object, drag in your player controller, that should solve your problem.

Also, just my advice, avoid using multiple cameras as you are giving your program a lot of overhead (unless its for a specific reason like split screen or a security camera effect that uses a raycast to detect the player and sound an alarm etc). Here's a link to explain how to do it https://youtu.be/ufVqeQSgrSE (https://youtu.be/ufVqeQSgrSE)

Happy coding!