playMaker

Author Topic: iTween Move By Functionality  (Read 4088 times)

rickmiranda

  • Playmaker Newbie
  • *
  • Posts: 11
iTween Move By Functionality
« on: August 03, 2013, 03:32:25 PM »
Hi
I'm building prototype with Playmaker.
I'm implementing an FSM on the main game object. The FSM is in idle state and using a TriggerEvent to detect a collision with another game object. Once the collision takes place, transitions to another state that will cause the main game object (player object) to rotate (Spin). I'd like to use the iTween Rotate By.

I know that the FSM is working properly when going between Idle and rotate sequence, when the iTween Rotate By is shut off. I shut it off to be sure that the player object is detecting collision correctly so I know the collision detection is working fine. But, when I turn on iTween Rotate By, whenever a collision happens, the FSM stays stuck in the Rotate State without going back to Idle Plus, there's no spinning action on the object.

Not really sure how I'm supposed to use the "Start Event" "Finish Event" dropdowns on the "Events" section of iTween Rotate By...but something about when the script gets to the iTween Action that causes the FSM to get stuck at the "Spin Out" (second state) and also something about it that is preventing from iTween from doing the action.

I've attached screenshots of both states and hopefully should give additional information about how I've put this together.

Please let me know if anyone has any ideas about how I can correct this. Thanks!
« Last Edit: August 03, 2013, 10:16:27 PM by rickmiranda »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: iTween Move By Functionality
« Reply #1 on: August 06, 2013, 04:23:16 AM »
Hi,

 iTween and physics together is not really a good idea.

 instead of using iTween, you should use physics, like applying torque or force.

what do you want to achieve when you use "Move by" tween?

bye,

 Jean

rickmiranda

  • Playmaker Newbie
  • *
  • Posts: 11
Re: iTween Move By Functionality
« Reply #2 on: August 06, 2013, 10:14:52 PM »
Hi Jean
Ok. What I'm trying to do is to make the player object spin when it collides with an obstacle. But I think I have this working well now using the "rotate by" action and "Time.delta".

The issue I'm having now is that I want to be able to transition between two different FSMs. One FSM keeps track of the objects idle states. These idle states are based on being at one of three positions (left, Center or Right of screen). I want to keep track of these 3 states because they determine if player can move left or right (so wont move off screen).

The second/separate FSM will be entered when player object collides with an obstacle. When colliding with an obstacle, will cause the player object to spin and translate to the next lane. This simulates a car splashing over an oil slick and spinning off to the next lane. This second FSM takes care of the spinning and translating to the next lane.

The problem occurs when the second FSM finishes. I don't know if I can exit the second FSM to enter back into the idle state of the first FSM. Since it doesn't do that right now, the idle state (center, left, right positions) can't update after the collision event. Any ideas on how to handle this, or do you know if/how to exit one FSM to enter a state in another FSM?
 

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: iTween Move By Functionality
« Reply #3 on: August 08, 2013, 03:42:01 AM »
Hi,

 I think you simply need to create a series of global events. and then fire these events in your various states. Other fsm will responds and act accordingly. They can in turn fire a global event for your fsm to listen and go back to where it was or to an idle state.

example:

FSM A: transit from idle state to another state "HIT", Fires a global event " PLAYER IS HIT"
FSM B: listen to "PLAYER IS HIT", does it thing and when done broadcast "PLAYER HIT ANIM DONE".
FSM A: listen to "PLAYER HIT ANIM DONE" and goes back to idle state.

Does that make sense?

bye,

 Jean