Ok so how would I avoid different players having things like raycast and so on colliding with specific things that are only meant for the specific player?
Like in my case I have a box collider around the player which detects certain things like a ray which is cast from the player. So I want to make sure that other players raycast also does not hit it and cause problems.
How to avoid it?
1 Answer
1
One way would be to have different layers for different players, and then setting up the layer collision matrix so that the different layers do not collide with each other.
A second option would be to have an owner id in the scripts, and then checking in OnTriggerEnter() whether the item collided with belongs to the correct player. This will only work on trigger colliders though, since non-trigger collisions will be resolved by the physics engine (the layer collision matrix will work for both)
Well the collider is a trigger. What I mainly(if not the only) thing I want to avoid is other players raycast hitting it. Ok so how would I get each new players collider into its own layer... Or give it a unique ID like you say? The second option seems better, would it also be better on the cpu?
– DeadKennyOh ok I think I know what to do now... Set the raycast to only hit a certain layer and give each players vision box its own layer which will be the layer per player. Confused myself a little on how to do that but I'll ask that later. Ok.
– DeadKenny