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?
Hi @Villager-13, I have a couple of suggestions that might help.
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
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.
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.)
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?