playMaker

Author Topic: How to find Who killed who ?[SOLVED]  (Read 1526 times)

heavygunner

  • Sr. Member
  • ****
  • Posts: 344
How to find Who killed who ?[SOLVED]
« on: December 31, 2018, 12:18:00 PM »
Hi !

Working on a small Topdown shooter game. Let's say there is 5 players shooting each others and dying. In this case, how to find Which player killed a player?

What I planned is, duplicate the buller object and tag each of them with player's reference.

is there any other ways to do it ?
« Last Edit: January 22, 2019, 03:25:43 AM by jeanfabre »

Thore

  • Sr. Member
  • ****
  • Posts: 480
Re: How to find Who killed who ?
« Reply #1 on: December 31, 2018, 12:33:42 PM »
Nope.

1. When bullet spawns, get owner of bullet (the player).
2. When bullet hits, store player it hit.
3. Send both info over to a score keeper, e.g. using the event info, set event data pair.  Depending on mechanics, only when kill, every time etc.

Compute that data in the score keeper. Make yet another FSM that gets that data from score keeper, and updates the UIs.


djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: How to find Who killed who ?
« Reply #2 on: January 02, 2019, 06:14:43 AM »
Hi.
You can also have a fsm on the bullet with a (int or string) variable.
On spawning the bullet use set fsm string/int. and give it the player name or nr that spawned the bullet.

on impact get the variable to know from who the bullet was.


Side note: for the bullets you should use pooling, do not create/destroy its bad for performance.

heavygunner

  • Sr. Member
  • ****
  • Posts: 344
Re: How to find Who killed who ?
« Reply #3 on: January 09, 2019, 05:57:10 AM »
Hi.
You can also have a fsm on the bullet with a (int or string) variable.
On spawning the bullet use set fsm string/int. and give it the player name or nr that spawned the bullet.

on impact get the variable to know from who the bullet was.


Side note: for the bullets you should use pooling, do not create/destroy its bad for performance.
Nope.

1. When bullet spawns, get owner of bullet (the player).
2. When bullet hits, store player it hit.
3. Send both info over to a score keeper, e.g. using the event info, set event data pair.  Depending on mechanics, only when kill, every time etc.

Compute that data in the score keeper. Make yet another FSM that gets that data from score keeper, and updates the UIs.

Thank you for the inputs.
Finally, Did it.

BTW, I increased Players count to 10. Is it okey to add 100 Bullets to Pool ? Each Player will have different rifles.

:)

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: How to find Who killed who ?
« Reply #4 on: January 09, 2019, 09:23:43 AM »
Hi.
It kinda depends on how many bullet a player can shoot before they are disabled again.

You can set 'can grow' to be sure not to run out of bullets.

but if there would be like 4-5 bullets max per player, i would set maximum to 50 and have 'can grow' as a fail save.

Things that are loaded in the scene use memory, so for mobile it would be more important not to have to much bullets loaded.