playMaker

Author Topic: Set rotation once and then move on to following state  (Read 2661 times)

axoona

  • Playmaker Newbie
  • *
  • Posts: 3
Set rotation once and then move on to following state
« on: August 10, 2016, 06:01:56 AM »
Hi,

I've just started playing with PlayMaker and I can't make work something that seems quite obvious though. So I would really appreciate your help :)

I want to change the rotation of an object (not rotate it but just set a new value of rotation so that the object gets instantly new rotation) and I want to do it only once. After that I'd like to dispatch a FINISHED event and move on to other states.

I am using the "set rotation" action with the desired value in the corresponding axis.
It works, but only if I tick: "Every Frame" and "Late Update".

However, because the action is set to be actioned every frame, the FINISHED event never dispatches. so it stays blocked in the current state and the fsm never proceeds.

Would anyone have any clue as to how to do it?

I've tried changing all possible options (space from world to self...), I also tried the "rotate" action... and nothing works.

thanks

kavery

  • Full Member
  • ***
  • Posts: 143
Re: Set rotation once and then move on to following state
« Reply #1 on: August 10, 2016, 08:24:40 AM »
Welcome!

For a quick fix when this happens you can place a 'wait' action of say .01 or however long you need to see results. Place it after the rotation. It's also good to know that actions fire in sequence within a state (unless it has a delay). Or you could use a send event action with a delay.

I get this problem every once in a while, where setting once doesn't work. Usually it means it's competing with another FSM or it's happening before the object is ready for input for some reason. (pre spawn, instantiate etc)
« Last Edit: August 10, 2016, 08:26:39 AM by kavery »

axoona

  • Playmaker Newbie
  • *
  • Posts: 3
Re: Set rotation once and then move on to following state
« Reply #2 on: August 11, 2016, 04:32:18 AM »
Thank's for the tip.

I have added a send event after a delay and that effectively changes the rotation of the object and the fsm moves to the following state. However... in the next state the object has again it's old rotation values set! I really don't get it (this next state is just get any key).

Just adding Wait doesn't seem to work. if I don't tick "every frame" the set rotation action doesn't seem to work at all. I've put 1 second delay and still it doesn't rotate if every frame is not set.

My state machine is really simple, I don't have others and the object is on the screen already. Basically what I want to do as a whole is :
- state 1: any key (the object is in 0)
- state 2: play animation (the animation rotates object from 0 to Z)
- state 3: rotate the object to 0 using "set rotation" and back to state 1

so what happens now is that in state 3 the object is rotated to 0, but when fsm goes back to state 1 the object is rotated to Z and then in state 2 the animation plays as expected (rotation from 0 to Z).

I suppose is the fact that every frame needs to be set in set rotation for it to work is maybe the core of this problem?

kavery

  • Full Member
  • ***
  • Posts: 143
Re: Set rotation once and then move on to following state
« Reply #3 on: August 11, 2016, 08:48:11 AM »
In this case the wait action is meant to work in conjunction with an 'every frame' action.. so that you can still get out of the state. But yea, seems like a symptom to your larger problem.

You didn't mention the use of an animation.. I'm assuming this is a clip of some sort that uses keyframes? It's likely hijacking your transform inputs. So the late update you clicked is attempting to override this.

You could opt to use a rotate action rather than keyframes (like rotate to). If animation clips are preferred, you'll need to get a handle on how they work. I'd need to see more on that side to help. You can experiment with stop animation actions etc. before entering state 1 again? They seem to be competing.
« Last Edit: August 11, 2016, 09:39:39 AM by kavery »

axoona

  • Playmaker Newbie
  • *
  • Posts: 3
Re: Set rotation once and then move on to following state
« Reply #4 on: August 14, 2016, 11:37:31 AM »
It worked! Thank's a lot! :)

I've added a stop animation action in the last state just before set rotation.
It's good to know that animations can still compete even though you might think they're finished.

kavery

  • Full Member
  • ***
  • Posts: 143
Re: Set rotation once and then move on to following state
« Reply #5 on: August 15, 2016, 09:45:48 AM »
Rock on glad it helped