Playmaker action possibly not working

hazuki

Member
Hi,

I am having trouble with the Has Taken Damage playmaker action where the Attacker game object variable is never populated and the 'Damaged Event' is never sent.

As you can see I am calling this ever frame and to illustrate that the action is looking at the correct UCC character I have included the Get Attribute Value which correctly registers the health change when the damage is dealt (this went from 100 to 90). I have tried this with other UCC charcters being both the attacker and the attacked and the action yeilds no results. Any help much appreciated!

Capture.PNG
 
When the character is damaged does the OnHealthDamage event get sent? You can debug this by placing a breakpoint within Health.OnDamage. If it does get sent, does the action correctly register for the event on line 41 of the HasTakenDamage task?

If the event is being sent and is being registered, is the same GameObject being used? This is the first parameter when registering/sending the event.
 
Sorry, i'm sturggling to do this, I don't code well hence needed playmaker support and even debugging the script is proving difficult for me, I've inserted the breakpoints where I think they should go but I think i have an issue with the link between unity and VS, so i'll try to solve that first but it's preventing me from answering your question at the moment. thanks for coming back to me.
Capture.PNG
 
Hi Justin, I continued to experiement with this and have isolated where the issue is.

The 'Damaged Event' will trigger only if the Target Game Object has been directly set, if the Target Game Object is provided by a Game Object variable (which in my case is required) then the event does not trigger.

It would be super useful to have this operating, i've looked at the script myself but it's beyond me!
 
So you're saying that the target variable is different depending on if the TargetGameObject field is filled in or not? At the start of the action it does a GetOwnerDefaultTarget so this value should be the same if m_TargetGameObject is null or if it is set to the existing character.

Code:
var target = Fsm.GetOwnerDefaultTarget(m_TargetGameObject);
...
EventHandler.RegisterEvent<float, Vector3, Vector3, GameObject, Collider>(target, "OnHealthDamage", OnDamage);

As a test I left TargetGameObject as "Use Owner" and the event was correctly set to the current GameObject.
 
Not quite. If the target game object is set to use owner it works, if the target game object was set by dragging and dropping the game object into the field then it also works but if the target game object is a game object variable (which has been correctly set), then the action doesn't work. I can screen capture this if it isn't clear, it's quite difficult to explain.
 
So I've done some more testing, it's really odd but basically it looks to me like the playmaker action does only functions if the Target Game Object is defined prior to runtime.

In the video below there are two separate FSMs, the first has had the Target Game Object defined prior to runtime, I demonstrate that this works.
The second FSM has the Target Game Object defined at runtime (via the Get Parent action), I demonstrate that this one does not work and Ishow that the Target Game Object appears to be set correctly.


Help on this would be much appreciated, my AI is being handled by a nested prefab and as such this issue hasstopped me from continuing work for a while now. Thanks!
 
Ah, I see. The target GameObject is being initialized within Awake and that doesn't update when the GameObject changes. I will have to put some thought into the best way to solve this - the action doesn't need to be active in order for it to receive the event and this poses a problem when you switch targets.
 
ok cool, thanks for looking into it, it was super difficult to figure out what was happening and to explain :)
 
Unfortunately I don't know of a way to handle the GameObject changes. In order for Has Taken Damage to work it needs to be registered ahead of time. But there isn't a callback from Playmaker when the GameObject changes so there's no way for the action to reregister for the event. The only way to reregister would be for the action to be run again, but at that point it's too late.
 
Is it possible for a separate action to be responsible for populating the game object prior to the Has Taken Damage being awake?
So it might go

State 1
[SetHasTakenDamageTarget = GameObjectX]

State 2
{HasTakenDamage]
I'm pretty desperate for a way around this as otherwise I'll need to move all of my AI out of a nested prefab and onto individual objects and that's going to be horrific!
 
Since you are dealing with prefabs can you instead assign the correct GameObject when you spawn the GameObject? This should assign the correct GameObject at runtime. Since you can't run multiple actions in parallel there isn't a way to create another action that reregisters the event. You could register the event when you assign the GameObject instance, though.
 
Ah, it was a little awkward but it works! I can set the game object to anything I want at runtime as long as the GO that has the HasTakenDamage action is activated after this is set. Thank you for the suggestion.
 
Top