x


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?

more ▼

asked Oct 06 '10 at 07:31 PM

Jeston 1 gravatar image

Jeston 1
129 8 9 16

Yup, I had the same problem: http://answers.unity3d.com/questions/20105/why-is-oncollisionenter-not-always-called. Using triggers instead did not solve my problem.

Oct 27 '10 at 01:42 PM Herman Tulleken

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.

Oct 27 '10 at 08:16 PM Jeston 1
(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

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.

more ▼

answered Feb 27 '11 at 02:52 PM

Peter G gravatar image

Peter G
15.1k 16 44 137

(comments are locked)
10|3000 characters needed characters left

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

more ▼

answered Oct 11 '10 at 07:20 PM

George Profenza gravatar image

George Profenza
1 1 1 4

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x2584
x1579
x320

asked: Oct 06 '10 at 07:31 PM

Seen: 2319 times

Last Updated: Oct 06 '10 at 07:31 PM