playMaker

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

BlanketsWilson

  • Playmaker Newbie
  • *
  • Posts: 13
How to Rotate Object in 90 degree increments with command.
« on: March 09, 2017, 11: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

  • Beta Group
  • Hero Member
  • *
  • Posts: 768
Re: How to Rotate Object in 90 degree increments with command.
« Reply #1 on: March 09, 2017, 12:12:04 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:


« Last Edit: March 09, 2017, 12:13:38 PM by tcmeric »

BlanketsWilson

  • Playmaker Newbie
  • *
  • Posts: 13
Re: How to Rotate Object in 90 degree increments with command.
« Reply #2 on: March 09, 2017, 02: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:


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

  • Beta Group
  • Hero Member
  • *
  • Posts: 768
Re: How to Rotate Object in 90 degree increments with command.
« Reply #3 on: March 09, 2017, 08: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: 15500
  • Official Playmaker Support
Re: How to Rotate Object in 90 degree increments with command.
« Reply #4 on: March 10, 2017, 01:27:45 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

BlanketsWilson

  • Playmaker Newbie
  • *
  • Posts: 13
Re: How to Rotate Object in 90 degree increments with command.
« Reply #5 on: March 13, 2017, 01:16:37 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

that would be great, thank you!!!!!!   :) :) :)

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: How to Rotate Object in 90 degree increments with command.
« Reply #6 on: March 20, 2017, 04: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: 15500
  • Official Playmaker Support
Re: How to Rotate Object in 90 degree increments with command.
« Reply #7 on: March 31, 2017, 03:03:55 AM »
Hi,

 ok, and the sample is now on the Ecosystem:

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

 Bye,

 Jean

misterjuly

  • Sr. Member
  • ****
  • Posts: 334
Re: How to Rotate Object in 90 degree increments with command.
« Reply #8 on: October 21, 2020, 04:38:34 PM »
Hello,
I know this post is old, but hopefully someone will respond. I'm having a hard time getting this to work. Here r my FSMs. Hopefully someone can help. Thanks!

misterjuly

  • Sr. Member
  • ****
  • Posts: 334
Re: How to Rotate Object in 90 degree increments with command.
« Reply #9 on: October 21, 2020, 04:39:51 PM »
Here r more pics (they would not fit in one message)

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: How to Rotate Object in 90 degree increments with command.
« Reply #10 on: October 22, 2020, 12:08:34 PM »
Hi.
I noticed 'loop don't finish is checked'.

maybe that's the issue

misterjuly

  • Sr. Member
  • ****
  • Posts: 334
Re: How to Rotate Object in 90 degree increments with command.
« Reply #11 on: October 22, 2020, 02:32:11 PM »
Nope. Didn't seem to be the issue. Also, I noticed I forgot to put in one of the keys, but that still wasn't the problem. Any other ideas?

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: How to Rotate Object in 90 degree increments with command.
« Reply #12 on: October 24, 2020, 02:45:30 AM »
Hi.
If you play and look to the fsm, can you see it looping thru the states?