- Home /
Network bullet issue
i have all working, i instantiate the bullet, and then if i hit an player, he loose life etc, but, when i shoot to the ground i dead, i think that my bullet is colliding with me, there is a way to make my bullet dont affect me? i tried to use ismine, but the bullet belong to everyone, so it dont work, there is a way to make my bullet dont hit my collider ? i cant find a way to my bullet search for who shooted the bullet, i dont want scripts, i want a explanation, please :D
Answer by Void24 · Feb 05, 2014 at 10:58 PM
The way I handle this is by giving each player an ID. Then, each projectile gets an "ownerID" that corresponds to the shooter and is set when instantiated.
You can check an ownerID against the ID of the player hit to determine if the hit should be processed.
Furthermore, you can set an "arming timer" that removes the ownerID after a certain distance, similar to how bombs are armed a set time after being dropped by planes. This will allow the bullet to potentially bounce around and hit the shooter, if you prefer.
so, i have my bullet script, what's the script to check the ownerID ?
I assume you have some sort of OnCollisionEnter event to kill a player on contact with a bullet?
If your player objects are already dying due to collision, just add a comparison before you destroy the player object. Compare the bullet's owner to the player. If they are the same, the player fired that bullet.
i've found a different solution. no i'm using raycast. but can you explain how i get the viewId of the player who instantiate the bullet ?
Your answer

Follow this Question
Related Questions
Photon (PUN) Type Serialization Error on RPC 2 Answers
Unity array out of range exception, using photon unity network. 1 Answer
How to instatiate two players simultaneoulsy before loading level 1 Answer
Photon networking 0 Answers
Smooth movement of non-player objects/vehicles over the network? (Photon) 2 Answers