playMaker

Author Topic: How to Rotate Object in 90 degree increments with command.  (Read 240 times)

BlanketsWilson

  • Playmaker Newbie
  • *
  • Posts: 3
    • View Profile
How to Rotate Object in 90 degree increments with command.
« 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,

tcmeric

  • Sr. Member
  • ****
  • Posts: 261
    • View Profile
Re: How to Rotate Object in 90 degree increments with command.
« Reply #1 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



« Last Edit: March 09, 2017, 10:13:38 AM by tcmeric »

BlanketsWilson

  • Playmaker Newbie
  • *
  • Posts: 3
    • View Profile
Re: How to Rotate Object in 90 degree increments with command.
« Reply #2 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.

tcmeric

  • Sr. Member
  • ****
  • Posts: 261
    • View Profile
Re: How to Rotate Object in 90 degree increments with command.
« Reply #3 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  ;)

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 11713
    • View Profile
Re: How to Rotate Object in 90 degree increments with command.
« Reply #4 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

BlanketsWilson

  • Playmaker Newbie
  • *
  • Posts: 3
    • View Profile
Re: How to Rotate Object in 90 degree increments with command.
« Reply #5 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!!!!!!   :) :) :)

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 11713
    • View Profile
Re: How to Rotate Object in 90 degree increments with command.
« Reply #6 on: March 20, 2017, 01:56:44 AM »
Hi,

 Here we go:



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

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 11713
    • View Profile
Re: How to Rotate Object in 90 degree increments with command.
« Reply #7 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