I have a space game heare where my main character is a fast moving space ship.
I have many objects in my scene which my space ship should be able to crash into .
I am using Occlusion culling on my camera so allowing the ship to even barely pass through any object is not an option.
My parent child relationship of my ship looks like this
▼ShipBody
Mesh
My ship currently passes through my objects even though i have placed a mesh collider on Mesh and a Rigidbody on ShipBody.
you can disregard what I have said but i would just like to know the best war to ensure continuous perfect collision detection.
First obvious question would be: Have you put a collider and Rigidbody on the objects you want to collide with as well? Also to ensure better continuous collision detection you can go into the ships (and objects) rigidbody and change the "Collision Detection" property to "Continuous Dynamic". Are you by the way moving your ship using force and velocity in rigidbody or translating it with transform?
– GameVortexyup I added rigidbodies to the objects to be collided with. I have tried setting the collision detection to continuous dynamic but i get the same result. I am moving the ship using Transform.
– AlanimatorReducing the fixedTimestep seems to have the biggest impact on mitigating this problem: Edit > Project Settings > Time. Try reducing the fixedTimestep from 0.02 to 0.01 to start. The smaller the number, the better the detection, but at the cost of CPU cycles. You might also take a look at this script: [http://wiki.unity3d.com/index.php?title=DontGoThroughThings][1] [1]: http://wiki.unity3d.com/index.php?title=DontGoThroughThings
– robertbuWhen moving the ship using the transform you are in reality just teleporting it to a new position each frame. No physics calculations are done. You can try moving it with .ApplyForce or .MovePosition of rigidbody instead. Or using the script that flaviusxvii provided belove.
– GameVortexwell yeah in actuality i'm just moving the position of the ship over short intervals using Transform .If thats the cause , it is rather problematic . I will try the code flaviusxvii linked me to . if that still does not work I will revert to using ApplyForce.
– Alanimator