Playmaker Forum
PlayMaker Help & Tips => PlayMaker Help => Topic started by: Dionysu5 on April 20, 2017, 09:38:40 PM
-
Hey guys, I am new to unity, this is probably my 5th week with it. Playmaker is making things a ton easier, as I am a art guy.
I am trying to flip my sprite with comparing the x axis. I get the float thing, but the thing I do not understand is how to store and use the vector 3. I cannot for the life of me get the vector to flip depends on the +/- of the x axis.
Please help!!!
-
I am not sure I get the situation 100%, so if my advice doesnt help, please let us know more about it. Sometimes it best to just describe what is happening in the game in plain language.
So you can make vector 3 variables just the same as floats. Vector 3 contains three floats together in one neat little box. It has a float for the x, y and z axis of your game object (a sprite in this case?). If it is a 2d game, it only needs a vector 2.
In the actions section of playmaker, there is a whole catagory for vector3 and vector 2 actions.
If you want to just compare the X from a vector 3 (which always contains all x y z, in that order), you can get the X "out" from the vector 3. Use the action "Get Vector3 XYZ". This will allow you to store the X into a float variable.
Once the X is in a float, you can do a float compare more easily.
(There is even an action to do the opposite. You can "make" a vector3 from three seperate floats. One float for each x, y and z. If you fail to set a float for one of those three axis, it will be 0). The action is called "Set Vector3 XYZ".
Summary: Really there is nothing too magical about vector3. Basically they were invented for convenience, so we don't need to always set 3 different floats each time. We use them pretty much exclusively for the position of things in 3d space. They can be set/get like any other variable type (string of text, float of numbers, etc). But sometimes we do need to get the floats out of vector3s to do specific things.
-
Hi,
You can simply store x in a fsm float, then multiply it by -1 and set it back into the vector. have you tried that.
Also, for fliping sprites you could simply use the scaling ( -1 will flip), and
Also, Have you studied the 2d platformer sample I recreated 100% in PlayMaker? I flip sprites too for the character.
And, I Also just created two new actions (https://twitter.com/JeanAtPlayMaker/status/855313111779164161) on the Ecosystem to set and get the flip values on a sprite, so that it's gives you more options to flip your sprite.
Bye,
Jean