- Home /
Unity3 CollisionDetection.Continuous for Bullets causing ricochet
I noticed some new rigidbody flags for collision detection methods in unity 3 so I am playing around with it now but was curious if anyone has tried to make a bullet with the new collision routines.
I added a rendertrailer to my bullet sphere and notice that the bullets are ricocheting around the static level mesh as opposed to calling 'OnCollisionEnter' when it ricochets... I guess we still have to do a raycast on a per frame basis?
The docs don't really give many details about the implementation of each flag: ContinuousDynamic, Dynamic, and Discrete.
So it is still better to mark a bullet as Discrete and raycast old -> new position each frame?
Yup, I had the same problem: http://answers.unity3d.com/questions/20105/why-is-oncollisionenter-not-always-called. Using triggers ins$$anonymous$$d did not solve my problem.
I basically ditched the new unity 3.0 features and kept with the old methedologies of raycasting old position -> new position and checking the info that gets passed back.
Answer by Peter G · Feb 27, 2011 at 02:52 PM
Your walls also have to be set to ContinuousCollisionDetection. Dynamic CCD is for moving objects and CCD is for any objects that they can collide with.
Answer by George Profenza · Oct 11, 2010 at 07:20 PM
I just started with unity, and don't fully understand the question, but are you trying to stop the bullet or handle a bullet collision ?
I wanted to stop projectiles into a wall, so I added a box collider to my wall, then looked for projectile collisions using tags:
function OnCollisionEnter(collision : Collision) {
if(collision.gameObject.tag == "projectile")
{
print("projectile hit at: " + collision.relativeVelocity.magnitude);
Destroy(collision.rigidbody);
}
for (var contact : ContactPoint in collision.contacts) {
Debug.DrawRay(contact.point, contact.normal, Color.white);
print(contact.point);
}
}
HTH
Your answer
Follow this Question
Related Questions
Raycast from inside an object 2 Answers
Bullet Shoot with RayCast don't destroy onCollisionEnter 1 Answer
Bullet Effect 2 Answers
RayCast Problem : 2d 1 Answer
Raycast bullet collision problem 1 Answer