Give Player Reward For Destroying Object

So I have a “mining rock” that after x amount of hits, it is destroyed. I want to be able to gain money from that rock once destroyed, but I can’t seem to hook up the Player’s reference to it.
What should I do?


(IMAGE BELOW: I included both the things I’ve tried so far. Casting and variable references)

Hi @Villager-13, I have a couple of suggestions that might help.

  1. Using GetPlayerCharacter
    By using GetPlayerCharacter, you can get a reference to your player. You can cast the return value of GetPlayerCharacter to your own player class and call a function or do what needs to be done. However, there will be more steps to this if your planning to have multiplayer
  2. Use Event AnyDamage Input Params
    The event your using, Event AnyDamage, has an input parameter named “Damage Causer”. This input holds a reference to the actor that damaged this “mining rock”. Which means that once the rock breaks you can give the reward to the player that destroyed it allowing multiplayer functionality.

Hope this helps! :+1:

For single players, you can call GetPlayerContoller 0 to get the controller for the player.

But, you will note that in the “event on damage” node, there is an “insitgator,” which is the actor that instigated the damage. So, you can go from that, to the player that did the damage. (Assuming you set the player as the instigator when you deal the damage.)

It doesn’t seem to connect. I swear it once did, but it didn’t work then, either.


Nor will any “Get player” nodes

Any other ideas?

No “Get Player” nodes seem to connect


Then for the Parameters, nothing connects. Not to the Target, not to “Get Player” nodes, nothing that should work.

Any other ideas?

You will need to cast from generic pawn reference to your particular subclass.

Half of that just went over my head.

I tried casting from my first person character because that had the correct connection to the function, but it doesn’t tie in with anything else (that’s the only casting I’ve tried). When you say “generic pawn reference” what does that mean?

Obviously cast to the class you need

1 Like

That worked! Thank you very much!

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