- Home /
The question is answered, right answer was accepted
Playmaker: How to use transform.position in actions
I want to move and object to an Y position, but NOT on the X axis, just in the Y. Lets say, I want to move it to y = -2. If I use an iTween MoveTo and put the Vector3 as 0,-2,0, the object moves to x = 0 too. If I use Move Towards, I can set the target position, but I need to put in the X textbox something like transform.position.x to leave the X position as it is. How this is done?
Answer by DarkSlash · Dec 11, 2014 at 07:05 PM
I have to do 3 actions, like in programming, but using Playmaker actions:
0) Create a Vector3 variable
1) Get the position an store it in the Vector3
2) Add to that vector -2 with the action Add Vector3 XYZ
3) Do a Move To the Vector3 variable that we created
Answer by M-G-Production · Dec 05, 2014 at 10:12 PM
Hi DarkSlash!
When you say move to "0,-2,0", you set absolute values wich are relative to the scene "grid".
In your case, you must make it relative to the object!
So There it is in C#:
transform.position = new Vector3(transform.position.x,transform.position.y - 2, transform.position.z);
Bests, Math
Of course that is the correct way, but I want to put that in the Playmaker action panel :)
And I want to move the object to y = -2, not to transform.position. y - 2; )
I'm sorry, I did not know about Playmaker visual scripting,
If you want Y to be absolute -2, I'm pretty sure you know how!
(ok ok... transform.position = new Vector3(transform.position.x,-2, transform.position.z); )
I can't help you more with Playmaker... But anyway, I tried to help!
Follow this Question
Related Questions
How to make vehicles move in forward AND reverse using a touch to move system 0 Answers
MoveTowards inside Coroutine 2 Answers
Smooth motion physics Playmaker 0 Answers
how to stop something from following in the y axis 1 Answer
Move Object Using iTween 2 Answers