Kill mechanic problem

“GetNearestPlayer” filters itself by comparing the distance to the player to 0.

I noticed that, however, it’s not entirely explicit enough. Imagine the killer is on the move while he presses the “kill” key. His location at that instance in time will be passed into the function. Meanwhile the get all actors of class will take some time (albeit very small) to execute and each run through the for loop will take some time (again, small but not nothing) to make it’s way through the loop. So by time you call “GetActorLocation” for yourself in the loop, you could have moved enough such that the distance is not exactly 0.0. It would be worth investing a little time here up front to make this more explicit and guarantee that GetNearestPlayer is in fact returning something other than itself. At the very least, print out the actor returned and make sure it’s what you expect.

As for the “GetPlayerCharacter”, I’ll change that later, that’s not very important for me now…

Fair enough…while debugging though, at least make sure you’re printing out something meaningful so that you can verify functionality. You don’t want to waste your time only to later realize that a function up stream wasn’t doing exactly what you thought.

I meant that my goal, for now, is to at least make it work locally for the victim

You won’t be able to do that without proper replication. You can only hope to get the functionality working for the killer, and even then only server side. Tackling multiplayer workflow is a different beast which requires you to think about the implementation from a replication perspective up front, not later, as this will guide every decision for the most part. Let’s take the “Tick” functionality for instance…you have a call to “Possess”. The server icon in the top right corner indicates that it only runs on the server…this means it has no meaning on the client. Next the “Remove All Widgets” function has a monitor symbol…that means that it runs for the local player only. There is no context to it, it simply removes any and all widgets on the local screen. That is why, under either scenario you provided, the widgets for the killer get removed.

It seems to me like there is some “running before walking” going on here. Even if you got this to work in some capacity as it is setup now, you will have no chance moving forward if you don’t first get a handle on replication to some extent. It is the foundation of any multiplayer experience you will make.

1 Like