Playmaker Forum

Playmaker Help & Tips => Playmaker Help => Topic started by: BlanketsWilson on March 09, 2017, 09:20:53 AM

Title: How to Rotate Object in 90 degree increments with command.
Post by: BlanketsWilson on March 09, 2017, 09:20:53 AM
Hey what's up, so I just downloaded PlayMaker today.

The main mechanic in my game is to being able to rotate the world clockwise/counter clockwise 90 degrees at a time, using keys.

As if you press the Q key and the world rotated CW once, stayed still, until that button is pressed again, or the E key is pressed to rotate the CCW. Similiar to how FEZ works. Being able to rotate left and right, however many times.

How is this possible?!

Thanks,
Title: Re: How to Rotate Object in 90 degree increments with command.
Post by: tcmeric on March 09, 2017, 10:12:04 AM
Its possible. First I would suggest watching some of the playmaker tutorials to get the hang of playmaker.

1.

Make a variable float, set it to 0. Thats your start rotation.

2.

Then use the "get key down" action, to move to the next state. Assign it to be Q. In the next state, use the "float add", and add 90 more to that variable.

3. Use a "get key down" for E. Use it to "float add" in another state. But this time use -90. (Float add, both add or subtract).

4. Decide how you will move the world. But probably easiest is make an empty game object. Maybe call it "whole_world". Then you just rotate this gameobject and everything that is a child will change too.

5. You can use an itween action or the regular rotate action in playmaker. So the rotation to be your variable. Set the rotation action to work on your new "whole_world" game object. And the rotation amount to be your variable. Viola.

If you have watched the first few tutorials, this will all make sense. At the very least, this first one: https://www.youtube.com/watch?v=I9VwsVtbgFU



Title: Re: How to Rotate Object in 90 degree increments with command.
Post by: BlanketsWilson on March 09, 2017, 12:07:05 PM
Its possible. First I would suggest watching some of the playmaker tutorials to get the hang of playmaker.

1.

Make a variable float, set it to 0. Thats your start rotation.

2.

Then use the "get key down" action, to move to the next state. Assign it to be Q. In the next state, use the "float add", and add 90 more to that variable.

3. Use a "get key down" for E. Use it to "float add" in another state. But this time use -90. (Float add, both add or subtract).

4. Decide how you will move the world. But probably easiest is make an empty game object. Maybe call it "whole_world". Then you just rotate this gameobject and everything that is a child will change too.

5. You can use an itween action or the regular rotate action in playmaker. So the rotation to be your variable. Set the rotation action to work on your new "whole_world" game object. And the rotation amount to be your variable. Viola.

If you have watched the first few tutorials, this will all make sense. At the very least, this first one: https://www.youtube.com/watch?v=I9VwsVtbgFU


Thanks for the reply. I'm pretty confused on how that would get set up using the nodes. Is there anyway you can set this up in a demo file. Basically, everything you said is what I need.

It would mean a great deal, and I appreciate it.
Title: Re: How to Rotate Object in 90 degree increments with command.
Post by: tcmeric on March 09, 2017, 06:39:31 PM
Sorry, I dont have time to do it for you. Keep trying, you will figure it out  ;)
Title: Re: How to Rotate Object in 90 degree increments with command.
Post by: jeanfabre on March 09, 2017, 11:27:45 PM
Hi,

 Let me know if you still struggle with this, I'll do a quick demo of this so you can get started.

 Bye,

 Jean
Title: Re: How to Rotate Object in 90 degree increments with command.
Post by: BlanketsWilson on March 13, 2017, 10:16:37 AM
Hi,

 Let me know if you still struggle with this, I'll do a quick demo of this so you can get started.

 Bye,

 Jean

that would be great, thank you!!!!!!   :) :) :)
Title: Re: How to Rotate Object in 90 degree increments with command.
Post by: jeanfabre on March 20, 2017, 01:56:44 AM
Hi,

 Here we go:

(http://i.imgur.com/JjsVs3K.gif)

let me know if you understand this, basically the trick is to use proper tweening, in this case I went for rotateBy which is a percentage of the rotation, hence why I use 0.25 value, it's a quarter of a full turn.

 Let me know if that's what you wanted to achieve? replcae the cube with your world root Object and everything is going to rotate.

 Bye,

 Jean
Title: Re: How to Rotate Object in 90 degree increments with command.
Post by: jeanfabre on March 31, 2017, 12:03:55 AM
Hi,

 ok, and the sample is now on the Ecosystem:

https://twitter.com/JeanAtPlayMaker/status/847705218993143808

 Bye,

 Jean