playMaker

Author Topic: Reset Camera on Button Click  (Read 1484 times)

davebr

  • Playmaker Newbie
  • *
  • Posts: 4
Reset Camera on Button Click
« on: May 20, 2020, 03:47:57 PM »
I have an application setup with four buttons that when clicked take you to a different camera. The cameras are called with an OnClick command in Unity. Once you are on any of the four cameras, I have a script that lets you pan and zoom around the scene. The problem is, if I pan the camera to a different area in the scene, when you click the button it does not reset the camera back to its original position.

I know there has to be a way to do this with FSMs but after several weeks of trying I am nowhere closer to getting this to work.

I am somewhat of a newbie with Unity and very much a newbie with PlayMaker but learning all the time.

Thanks!

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Reset Camera on Button Click
« Reply #1 on: May 20, 2020, 04:29:20 PM »
Hi.
when you set a camera, can you use 'Set Rotation' and 'Set position' with the default camera location.

you can get the Position and Rotation @ start and use those variables to set back to.

davebr

  • Playmaker Newbie
  • *
  • Posts: 4
Re: Reset Camera on Button Click
« Reply #2 on: May 20, 2020, 04:46:37 PM »
Thanks for the reply.

I have variables setup with the position and rotation.
Would an FSM with those be attached to the button object or the camera though?

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Reset Camera on Button Click
« Reply #3 on: May 21, 2020, 02:47:12 PM »
Hi.
i can be on both.

But i would set a single fsm (can be on any object)

For 'button listener' state, use Ui Button array, set it to 4 and place the button game objects.

then you can set a transition for each button.

then on the other states (connected from the 'button listener' state)

You can set the position/rotation
You can drag the camera game objects in there
For example on "Set rotation" on 'game object' click on 'use owner' then you can select 'Specify Game object.
then you can place the camera object.