Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: TVISARL on April 16, 2019, 12:21:48 PM

Title: Observing a ship under way
Post by: TVISARL on April 16, 2019, 12:21:48 PM
Hi,

For a game involving ships, I would like to get a "kind of" follow action.
The camera is parented to a ship, and now I want it to move around the ship ( using the aroow keys ) as it is under way, and yet looking at it  all the time ( for this, I use the "Look At" action).
Problem : when I release the arrow key the camera gets back to the same position and angles ( relative to the ship ) it had before ; what it should do now is to keep following the ship, looking at it from the new observation point.

How can I do  that ?

Thanks in advance.
Title: Re: Observing a ship under way
Post by: djaydino on May 08, 2019, 09:29:15 AM
hi.

it might be better not to parent the camera to the ship.


Make an empty object (call it 'camera root' for example) in the root of the hierarchy, add an fsms.

on the fsm do this :

Quote
state 1 :
'Get position' and target the ships parent object, use 'Space' World
'Set position' target owner and use the result variable from the Get position

make another child inside the 'Camera Root' (Call it 'Camera Holder' for example)
make sure that the position is set to 0,0,0
and inside that one place the Camera. position the camera on the desired distance. in a way that it is pointed toward the center of the 'Camera Holder'

Now you can rotate the 'Camera Holder' and the camera should stay pointed toward the ship.

now
Title: Re: Observing a ship under way
Post by: daniellogin on May 08, 2019, 10:25:58 AM
on the fsm do this :

Quote
state 1 :
'Get position' and target the ships parent object, use 'Space' World
'Set position' target owner and use the result variable from the Get position
Hey I've actually been wondering how 'expensive' it is to be setting the position of an object every frame like this. Is it a trade off between a performance decrease and some other benefit, or is it practically 'free'?

Also... what is the benefit of it in this kind of situation? This would be in comparison with simply having the camera holder as a child of the ship.

I actually just used this sort of deal in my current project, but I only actually did it because I wanted to mimic and objects position as well as Y rotation, but not have the X and Z rotation (which would be harder to avoid if it was an actual child, not set position + set rotation).
Title: Re: Observing a ship under way
Post by: djaydino on May 09, 2019, 01:40:22 AM
Hi.
Performance wise you should be fine with this.

Since a few years ago i almost always have the camera separated, as it gives a lot of freedom to the camera.
for example add some damping on the following.
Or
For example if your 'ship' would get a rowboat later on in the game that you would want to follow when deployed.

Also instead of Get/Set Position you can use Smooth Follow (if you do so, you can use 2 of them. one for Horizontal and one for Vertical to have different smooth time for each direction)
This gives a better feel on the camera.