- Home /
Killer + assistance id for shooter game
Hi!
I have something like ApplyDamage (hp system on enemy) and Shoot (attack system on player). Any idea to develop a killer id for +1 score to player(killer)? And for +1 (to killer and assistance) for cooperative attacks?
Thx for read. Thx for help.
I think my bullets need one varible like "bulletfrom". I work in it.
Are you using physical bullets? This would be needed. Raycasts are faster and more consistent for guns though, and you can call ApplyDamage directly through that.
Yes. I'm using physical bullets (instantiate prefabs) and now reading raycast info. Probably work but Raycast dont have parameters for killer. Anyway thank you for opening another way of research. I will study it.
Could the player not just keep a small buffer of players who recently damaged them and then give score accordingly? If the player dies, then you already have the ID of the killer, then you just check the last person(s) who dealt damage to apply assist score.
Answer by madks13 · Aug 03, 2018 at 01:17 PM
You should use an event system, similar to c#. You launch an event by giving the sender and event parameters. That way you would only have to see who fired the bullets to update the scores.
The sender can be of type System.Object, Unity.Engine.Object or Unity.Engine.GameObject, then you would get some kind of id (GetHash?) to identify the player/enemy.
Should mention that this won't work over the network. OP didn't specify but this sounds like a multiplayer game. This is probably the best way for singleplayer though.
As far as i know, in normal Unity (non ECS), the Unity player reproduces all game objects inside the server, so instantiating bullets should work fine. Also, the asynchronous multiplayer games use event systems to coordinate clients, so it should work too if implemented properly.
Thx for helps. I work in it. If I find a resolution code i will publish it, sure.
Your answer
Follow this Question
Related Questions
Trying to get my spawn manager to respond to the current score 1 Answer
Storing high score 2 Answers
Kill Counter --> Score 2 Answers
Kill Player Method Doesn't Work ? 0 Answers
Count the Score 1 Answer