- Home /
Two gameobjects with rigidbody aren't colliding in network game
I'm having an issue with two gameobjects representing players. Collision works when they run into items on the map (which makes sense since that's local for each of them), but they don't seem to successfully collide with each other. Instead, they move through each other.
Is there something I'm missing in order to enable them to collide with each other?
Answer by Lethil · Jul 02, 2012 at 12:27 AM
I found the problem. It was a simple one: I was trying to collide 2 mesh colliders. I just found out that can't be done. I don't need precision, so I switched to 2 sphere colliders and it works like a charm!
Answer by Berenger · Jun 22, 2012 at 11:14 PM
They might be triggers, or on layers that don't collide with each other. I suppose you're using AddForce to move or else you wouldn't collide with items. Try implementing OnCollisionEnter and OnTriggerEnter in scripts attached to those character, to check if something happens.
Answer by Lethil · Jun 22, 2012 at 11:23 PM
They're both clones of the same object and are both on the same layer. I use AddRelativeForce and AddRelativeTorque to move and rotate them. They have an OnCollisionEnter() call on their script, but not an OnTriggerEnter().
Collision is set to ContinuousDynamic.
Answer by sweatyrat · Jun 28, 2012 at 08:01 PM
what is your NetworkView.observed? you should have it set as the objects rigidbody. and if so then it has to be a problem with the server's collision detection because the clients will just do what they are told. are you applying those AddRelativeForce and torque on fixed update? that messes it up sometimes as well.
but if you are manually serializing values by setting your script as the NetworkView.observed then my guess would be there is a problem with the implementation there. like you have both the server and clients apply the values from OnSerializeNetworkView(stream : BitStream, info : NetworkMessageInfo) {} when stream.isWriting or something.
I'm doing some refactoring to make my code authoritative-based. Once that's done, I'll test run through your thoughts here and see if they fix the issue. I was on fixed update for Force and Torque, but I've moved them both to Update. :)
Your answer
Follow this Question
Related Questions
how effect physically on the other game object with rigidbody when collision in the network unet 0 Answers
How to add physics to an animation? 3 Answers
How can I apply a force to an object in the opposite direction of the object it's colliding with? 2 Answers
Objects with colliders going through walls and each other. 3 Answers