playMaker

Author Topic: iTween Animation in State  (Read 2474 times)

gregmax17

  • Playmaker Newbie
  • *
  • Posts: 11
iTween Animation in State
« on: September 20, 2012, 01:19:55 PM »
I have a InGame state on my character which has several actions such as move towards, on trigger enter events, get mouse button, etc. When the user right clicks, I tell it to switch to a new state called Spin. In my Spin state, I have a iTween Rotate Add action. The thing is, I want this Spin state to run this iTween animation and jump back into the InGame state, without have the FSM wait for the iTween animation to finish.

Does this make sense?

Otherwise, I have to copy all the other actions in the InGame state to the Spin state (the move towards, on trigger enter events, get mouse button, etc).

Is there a better way of doing this?

kiriri

  • Hero Member
  • *****
  • Posts: 506
Re: iTween Animation in State
« Reply #1 on: September 20, 2012, 03:44:20 PM »
not sure if I got this right. You want to rotate an object and still receive input at the same time?
To do that, simply create another FSM on the same object, then all your "Inputs" FSM needs to do is to send an event to that other FSM. The send event action is for all sense and purpose instant. After sending that event, you can again receive your other inputs.

These "sub FSMs" such as your rotation one don't have anything in their start state. They have another state with a global event input like "active" which, for ease of use, you should probably name the same on all generic sub FSMs . Now, if you send the event "active" to the sub FSM, it'll trigger the rotation, and on finishing it, it should go back to the start state, so if you're having an FSM which relies on checking whether one of your sub FSMs has finished (by checking the active state name), that can work properly.

Connecting your FSMs properly is really crucial on larger projects. I hope I could cover some basics just now :)
« Last Edit: September 20, 2012, 03:45:55 PM by kiriri »
Best,
Sven