playMaker

Author Topic: Move Object to Another Objects Transform?  (Read 3889 times)

mTruly

  • Junior Playmaker
  • **
  • Posts: 98
Move Object to Another Objects Transform?
« on: March 31, 2016, 07:18:48 PM »
If I have 2 cameras... CAM_A and CAM_B and I want to have CAM_A adopt CAM_B's precise position and rotation, what is the best way to go about this?

I have a state with actions:

Get Position - gets CAM_B's position into a vector3 variable
Set Position - sets CAM_A's position to that variable
Get Rotation - gets CAM_B's rotation into a vector3 variable
Set Rotation - sets CAM_A's rotation to that variable

But nothing happens visually... when entering this state, the view of CAM_A doesn't change to be the same as CAM_B.

I'm sure I'm doing something wrong.

Thanks for any ideas!


mdotstrange

  • Hero Member
  • *****
  • Posts: 555
    • Can't code? Who cares! Make games anyway!
Re: Move Object to Another Objects Transform?
« Reply #1 on: March 31, 2016, 07:56:52 PM »
If they are all in the same state- the set position could happen before the get position which you don't want-

You can separate them into two states- one with the get actions and one with the set actions-

I have a similar setup for moving a camera to and from positions-

I get the position than use a "move towards" action to move it to the position- it allows for a smooth transition which is what I need- if you want it to pop into position set position works fine-

For the rotation I want the camera to look at a target so I use a "Smooth look at action" and again thats for a smooth transition- if you want it to pop into rotation set rotation works fine
Indie game dev and instructor at the Strange School. Learn Playmaker at the Strange School!

mTruly

  • Junior Playmaker
  • **
  • Posts: 98
Re: Move Object to Another Objects Transform?
« Reply #2 on: April 01, 2016, 10:18:16 AM »
Thanks very much for the info!

Turns out, what I had setup should have worked fine... but there was a script on the camera object that was preventing the camera from moving to the new transform.

This script is OrbitCam (which is used for orbiting the camera around an object).  When this script is disabled on the camera, the camera properly switches between different transforms.  When it is enabled, the camera won't move.

Thanks again.