This project has moved and is read-only. For the latest updates, please go here.

Properties of Bullets vs Targets?

Topics: Developer Forum, User Forum
Aug 17, 2007 at 12:41 PM

I have been playing around with some Bullet physics.

However bullets appear to get "stuck" on the target object, and then raise a collision a bit later.

Obviously the intention is for the bullet to (depending on the projectile type, eg bullet vs rocket) apply some force to the collided object.

Here are the properties I have on a Bullet projectile and the object being hit:
RotationalDragCoefficient = 0;
LinearDragCoefficient = 0f;
FrictionCoefficient = 0f;
RestitutionCoefficient = 0f;

This makes the bullet travel on the 2D Space at a constant speed (which is what I want) however as above the collision occurs and the bullet get embedded/stuck onto the end of the target instead of immediately raising a collision.

What am I doing wrong? Which properties should I be looking at?

Aug 17, 2007 at 8:03 PM
I'm not sure on this. For one, your bullets might be moving so fast they are penatrating to deeply into the other object. If the bullets are getting embedded in the other objects the this is probably the case.
Aug 18, 2007 at 9:26 AM
I managed to get particles to collide as expected when using bullets as PointRigid objects instead of RectangleRigid.

Are they better at handling collisions (being small in size)? Appears so.
Sep 2, 2007 at 5:18 AM
I'm curious about that...just glancing at the collision detection code, it doesn't look like PointGeometries get any special treatment, but I could be mistaken. My own strategy for bullets has been to go outside of the physics engine -- each timestep I test the linear path of the bullet's motion, first checking if it crosses each objec'ts AABB, then testing for intersection with each edge of the geometry. Closest intersection to the bullet's location at the beginning of the timestep wins. Line intersection is substantially slower than grid lookup, although there's no need to break the line into smaller pieces as it is for normal collision detection, so for some geometries you need far fewer tests than there are vertices. But the major benefit is that you get perfect accuracy no matter how fast it's moving. This wouldn't work for larger objects of course, which would require intersecting areas to do accurate sweep tests.
Oct 4, 2007 at 5:24 AM
One way for Farseer to be able to help with this would be to support a 2D casted ray for collisiondetection against the objects col-shape. Currently I'm looking at adding this outside Farseer, which might not be optimal at all times.

Oct 4, 2007 at 11:04 AM
You have the source so you could add it inside Farseer. :-) I know that can become a pain when updates roll out but it's an option.