playMaker

Author Topic: How is this game object being assigned?  (Read 2103 times)

cats00eye

  • Playmaker Newbie
  • *
  • Posts: 47
How is this game object being assigned?
« on: September 23, 2015, 03:53:49 PM »
I have an object which uses a child to check for close objects. When its trigger sends an event, it checks the parent which stores the current target. If the current target is null, which at the start it always is, it then goes on to check if it's in field of vision, in line of sight, etc. If it is in field of vision, line of sight etc., it sends a global event to the parent, telling it there's a possible target. The parent then runs a few more checks on the possible target before setting the possible target as the current target. This, right at the end of the parent FSM is where the assignment of the game object CurrentTarget happens. Nowhere else.

And yet...

What is actually happening is, in the child object (the watcher) when the close object sends the trigger event, it goes to a state to check if it's the same as the existing CurrentTarget. This gets the value of CurrentTarget from the parent and simply compares it to the trigger object. Since at the start, CurrentObject is null, they are not equal. Debugging so that each step moves to the next state in any FSM, shows that this is indeed the case. The trigger object has a value and the CurrentTarget is null. However, the not-equal transition event is not triggered. Adding an equal transition event (for debugging purposes) shows the state following this equal event to a dummy state. Once this dummy state has been reached, checking back to the previous state (where the compare happened) we find that, somehow, the CurrentTarget has been assigned and the compare is now equal.

My questions are:
1) Given that we have stepped from one state to "the next state in any FSM" neither of which assigned CurrentTarget, how could CurrentTarget get assigned?
2) Given that the only state in the entire game that CurrentTarget is ever assigned is some while after the child (watcher) sends a global event to the parent and the child cannot send that event if the result of the object compare (described above) is equal, which it stubbornly is - again, how could CurrentTarget get assigned?
3) If the two objects are not equal at the time the state is being run, how is it possible that this equal condition is being met?

Sorry for the verbosity. I'm just trying to be clear. This looks literally impossible to me. What am I missing?

cats00eye

  • Playmaker Newbie
  • *
  • Posts: 47
Re: How is this game object being assigned?
« Reply #1 on: September 23, 2015, 04:53:58 PM »
Apologies, I'm a newbie. I've solved the problem by adding a break point to the assignment state and opening the log window, which I'd forgotten about.

There are two points that caused the confusion. First, I expected, on pressing pause, then play, that it would stop at the first state it came to, but in fact it had already passed through the assignment state, which is awkward to say the least. I suppose put a break point on the first state would be a work around for that. Second, very strangely, immediately after passing through the assignment state, that state's debug showed the new value for the CurrentTarget as it should. However, the state in the child (watcher) that I was having trouble with still showed Current Target to be none. I'm not sure how best to guard against that. Can anyone suggest why this would be happening?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15620
  • Official Playmaker Support
Re: How is this game object being assigned?
« Reply #2 on: September 24, 2015, 09:37:29 AM »
Hi,

 Have you tried stepping instead of hitting play after pausing?

in your second issue, it's likely because the child did not get updated yet, the breakpoing interrupts the stack of call, so it may interrupt while playmaker framework is processing all current actice states actions  to update them.

Could you maybe make a screencast to explain the problem, I'll look at it and see if there are ways to get around this.

Bye,

 Jean


cats00eye

  • Playmaker Newbie
  • *
  • Posts: 47
Re: How is this game object being assigned?
« Reply #3 on: September 25, 2015, 06:22:03 AM »
Thanks for the reply. Yes, I'm starting to learn how to get around all this now. Should have struggled with it a bit more before bothering this forum. I'm sure I'll have other questions though! Thanks.