colliders but no physics

Hi

I’m trying to create a simple snooker type behaviour but figured it’d be better to use some simple ball physics instead of using the Unity physics engine as it’s for the iPhone.

Now I have the collisions between balls working fine using some simple physics code and can get collisions working fine most of the time on the walls by using colliders and Vector3.Reflect in an onCollisionEnter function. My problem arises in certain instances, usually when a ball goes into a corner, in that the physics engine is still operating on the balls from the wall collider. This combined with my code that tells the ball hwo to behave on collision causes the ball to get stuck in the wall and just vibrate along it.

So my question is can I use colliders and a rigidbody (which is the only way to obtain a onCollisionEnter callback which I need to get the contact point and normal to calculate the correct reflection angle off the wall) but turn all the actual physics off. Or is there an easy way of getting exact collision points and normals of spheres with mesh colliders without using a rigidbody.

I could of course just use the physics engine to do all this instead but with potentially up to 20 balls in play in the game we’re creating i thought this would likely cause frame rate issues on the iPhone. The other problem i found when trying this was getting very accurate physics responses which this game relies on. I found the bounce off the walls in particular to be quite unpredictable (sometimes bouncy sometimes would not bounce at all). Has anyone here had these issues using Unity iPhone?

Thanks for any help

Paul

If you choose your object as Kinematic it will not be affected by physics :slight_smile:

Thanks for replying.

However, if you make a rigidbody Kinematic then onCollisionEnter callbacks are not triggered and these are the only reason i’m using a rigidbody.

Another way to approach this might be to use the physics engine, but aim to reduce the amount of work it has to do. I’m thinking maybe you could remove the collider that forms the table surface and keep the balls at the right height by applying forces. You could also set maxAngularVelocity to zero for the ball rigidbodies. You’d get the effect of balls sliding rather than actually rolling, but you could simulate rolling by rotating the mesh if necessary.

cheers - will look into doing it using physics again to see if it’s a goer - just seems like a sledgehammer to crack a nut as they say as the code to emulate simple 2D ball physics which is all i require is so simple.

if anyone out there knows a way of using colliders (in particular getting collision callbacks with contact normal info) without any physics being applied it’d be great to hear :slight_smile:

I found a solution on that. You can add a rigid body to your object and add a fixed joint to some root object. The fixed joint will maker sure your object moves only when your root object moves. And because of the rigid body you are able to raise oncollisionenter events.

I’d just crudely add another collider to the corner and addForce based upon trajectory. Even if its a bit off, you can still program it to move more specifically.