playMaker

Author Topic: Constrained Rotate  (Read 1433 times)

adrian34

  • Playmaker Newbie
  • *
  • Posts: 4
Constrained Rotate
« on: March 14, 2017, 05:49:25 AM »
Hi everyone,

Newbie question (again).

I have this mini-gun I can currently turn by 1 degree upon each(and every) key-press, but i can't figure out a way to constantly keep rotating by 1 degree while key is down, up to a certain amount (-30,30 in the x, and -90,90 in the y).

I use "Get Key Down" actions to fire up the transitions which doesn't look right.

I have a feeling i need a different approach/action. Can anyone help out?

Thanks!

adrian34

  • Playmaker Newbie
  • *
  • Posts: 4
Re: Constrained Rotate
« Reply #1 on: March 14, 2017, 10:58:28 AM »
Nailed half of my initial question by inserting a "Get Key Up" on the "Rotate" States, although this means you can't turn it diagonally yet, so I'm still certain there's a much better way than that I'm currently going with.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Constrained Rotate
« Reply #2 on: March 15, 2017, 08:58:12 AM »
Hi,

you need two/three fsm to make it very easy, one for rotating horyzontaly and one vertically ( when you'll get more expert, you can do it in one), one for constraint.

on key down, rotate incrementally every frame and listen to the key up meanwhile which will transit back to the state where you listen to the key down.

 by doing so, you can't really manage two keys in one fsm ( as an Fsm can only have active state at a time).

 if you feel adventurous and want to do in one fsm, one state, use GetAxisVector which give you a two axis definition, inject the result into the "Rotate" action.

For constraint, please check the Space shooter UnityLearn remake 100% in PlayMaker, it shows how to constraint the ship within an area, use the same technic for rotation:

-- get the rotation
-- clamp the rotation
-- set the rotation

the key is to use the Advanced version of theses actions ( found on the ecosystem), because you must do this on late update for no jitter to be visible else you'll have a race condition between your key willing to rotate passed the limit and the constraint bringing it back.

Let me know how it goes :)

 Bye,

 Jean