playMaker

Author Topic: Observing a ship under way  (Read 280 times)

TVISARL

  • Playmaker Newbie
  • *
  • Posts: 3
    • View Profile
Observing a ship under way
« on: April 16, 2019, 09:21:48 AM »
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.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 4537
    • View Profile
    • jinxtergames
Re: Observing a ship under way
« Reply #1 on: May 08, 2019, 06: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
FOR HIRE:Playmaker/C#

Playmaker Samples <-------------> Easy Exporter <---------------------> TPA Actions

daniellogin

  • Full Member
  • ***
  • Posts: 158
    • View Profile
Re: Observing a ship under way
« Reply #2 on: May 08, 2019, 07: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).

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 4537
    • View Profile
    • jinxtergames
Re: Observing a ship under way
« Reply #3 on: May 08, 2019, 10:40:22 PM »
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.
FOR HIRE:Playmaker/C#

Playmaker Samples <-------------> Easy Exporter <---------------------> TPA Actions