playMaker

Author Topic: FSM Structure, update sequences, etc (solved)  (Read 2598 times)

jayhfd

  • Junior Playmaker
  • **
  • Posts: 71
FSM Structure, update sequences, etc (solved)
« on: December 09, 2011, 01:24:54 AM »
Hi,
I think I need some more schooling on structuring my FSMs. I'm encountering some situations that are confusing me, and I think they may be to do with sending global events, when they are received, the fastest way to get things to happen, the order they happen in, etc.

As per my last solved thread (which is only semi solved...), I'm storing a collision contact point and then measuring the angle from the player to that point. I've also setup a debug FSM that pauses every time I hit the ground so I can examine a debug line pointing to the collision point position.

What I've found is that times where I should be recording an angle to the ground of 90deg (parallel), the update speed seems to be too slow (despite the game running quite fast), so what happens is that I've seen the debug ray pointing back (where the player touched the ground maybe 1-2 frames ago?), which is enough to tell the game that the angle is actually more like 130 degrees, which messes things up...

To initiate these actions I'm using a global TOUCHDOWN event, so I'm assuming all FSMS with this global transition do everything in the same frame? Or is it not that simple? How can I ensure that the angle/point I'm measuring is on the same frame that I touch the ground?

Another thing that has had me baffled with this same issue, is that I'm trying to use a simple Get Angle to Target, but for some reason I can't seem to get it to store a variable unless there is no transition out of its state. So I would like to store the angle just on the one touchdown frame, then use that variable, however if I ever try and do anything with it or FINISH/transition, it just stays at zero.

This leads me to generally think that I'm doing something wrong, or maybe just dont understand transitions that well at all! Would love any help you can offer.

Regards,
Jay
« Last Edit: December 13, 2011, 06:13:32 PM by jayhfd »

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 4000
  • Official Playmaker Support
    • LinkedIn
Re: FSM Structure, update sequences, etc
« Reply #1 on: December 10, 2011, 11:25:45 PM »
GetAngleToTarget uses LateUpdate, so in your situation it's never called (since indeed all events are processed in a single Update, so the state is no longer active when LateUpdate would be called).

You could try changing OnLateUpdate to OnUpdate in GetAngleToTarget.cs. I'll add this as an option in the next update...

Let me know if this helps!

jayhfd

  • Junior Playmaker
  • **
  • Posts: 71
Re: FSM Structure, update sequences, etc
« Reply #2 on: December 13, 2011, 06:13:15 PM »
Thanks Alex, that's definitely what was causing it. I ended up using some other work around, but I might give this whole thing another go now and see if I can figure it out. Looking forward to showing you the game soon!