playMaker

Author Topic: vector 3 rotate towards  (Read 639 times)

hydrazkiller

  • Playmaker Newbie
  • *
  • Posts: 2
vector 3 rotate towards
« on: December 11, 2022, 12:29:58 AM »
hello everyone,

does someone have an example or know how to use vector 3 rotate torwards? i dont know how to get the vector direction

drown

  • Junior Playmaker
  • **
  • Posts: 58
Re: vector 3 rotate towards
« Reply #1 on: December 11, 2022, 06:12:27 PM »
The action name might be confusing you.The action takes a Vector3 value and shifts it towards a target Vector3 in a certain amount of time. How can you use it? Let's use the action to rotate a cube by 90 degrees.

1. Add an FSM to the cube.
The cube we want to modify needs an FSM on it.

2. Add the Vector3 rotate towards action
Add the action to the initial state. Assign a Vector3 variable currentDirection to the "current direction" field. Set the target Direction to X0 Y90 Z0. This will rotate the cube 90 degrees on the up axis.



3. Set the cube's own rotation to the currentDirection variable
Now to explain what vector3 rotate towards does: it updates the currendDirection variable we assigned until it matches the target direction. That did not apply the rotation to any object. To do this, we need the Set Rotation action to apply the updating currentDirection value to the cube's rotation. Since we are using Vector3's we need to use the Euler Angles slot so the rotation is set properly.



Hope this helps!
« Last Edit: December 11, 2022, 06:14:52 PM by drown »