Agent not working in Verse

Hey i am new in verse and followed a video about how to get the Player who damaged someone and the example in the video was how to send back damege to the Damage dealing Player with “FortCharacterInstigator.Damage(2.0)” and now i wanted my trackers value the Damage dealing player and used

 HandlePlayerHit ( DamageResult : damage_result ) : void =
        Target := DamageResult.Target
        Amount := DamageResult.Amount
        if (FortCharacterWhoWasHit := fort_character[Target]):
        if (Instigator := DamageResult.Instigator?, Agent := Instigator.GetInstigatorAgent[], FortCharacterInstigator := Agent.GetFortCharacter[]):
            TargetValue7 := Tracker8.GetValue(FortCharacterInstigator)
            TargetValue6 := Tracker7.GetValue(FortCharacterInstigator)
            TargetValue5 := Tracker6.GetValue(FortCharacterInstigator)
            TargetValue4 := Tracker5.GetValue(FortCharacterInstigator)
            TargetValue3 := Tracker4.GetValue(FortCharacterInstigator)
            TargetValueNew := Tracker3.GetValue(FortCharacterInstigator)
            TargetValue2 := Tracker2.GetValue(FortCharacterInstigator)
            TargetValue := Tracker.GetValue(FortCharacterInstigator)"

for it but here FortCharacterInstigator is marked red. Would be happy over any reply :slight_smile:

If you hover your mouse over the red error, what does it say the error is?

1 Like

The damage could be done by some world object, so you must tell him that it could not be an agent.
To do this, we use Option.
This is the fix:

HandlePlayerHit ( DamageResult : damage_result ) : void =
        Target := DamageResult.Target
        Amount := DamageResult.Amount
        if (FortCharacterWhoWasHit := fort_character[Target]):
        if (Instigator := DamageResult.Instigator?, Agent := Instigator?.GetInstigatorAgent[], FortCharacterInstigator := Agent.GetFortCharacter[]):
            TargetValue7 := Tracker8.GetValue(FortCharacterInstigator)
            TargetValue6 := Tracker7.GetValue(FortCharacterInstigator)
            TargetValue5 := Tracker6.GetValue(FortCharacterInstigator)
            TargetValue4 := Tracker5.GetValue(FortCharacterInstigator)
            TargetValue3 := Tracker4.GetValue(FortCharacterInstigator)
            TargetValueNew := Tracker3.GetValue(FortCharacterInstigator)
            TargetValue2 := Tracker2.GetValue(FortCharacterInstigator)
            TargetValue := Tracker.GetValue(FortCharacterInstigator)"

I have simply added a ? after Instigator:

Agent := Instigator?.GetInstigatorAgent[]
1 Like

Hey this is the problem hope this helps you

Sorry for my late respond. I have checked your tip and added the “?” and now the “?” and the “FortCharacterInstigator” are marked red

The Tracker’s GetValue function expects an Agent, not a FortCharacter. So either give it a parameter of type Agent, or you could use the Player as well. Either one should work.

1 Like

How do i need to rewrite my script to make the FortCharacter an Agent?

My bad, didn’t see you put already the ? When defining Instigator. Revert that thing I said

1 Like

Just put Agent inside the brackets

1 Like

TargetValue := Tracker.GetValue(Agent)

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.