custom collision?

Hi guys,
What I’ve got is a rail shooter of sorts, where the player can control an object moving left/right to avoid obstacles, while the object continues to move forward at a constant speed.

The aspect that I would like to implement is an invisible wall along the sides of the track. If the player crashes against the wall at any angle that isn’t perfectly perpendicular to the wall, he should “slide along” the wall, rather than simply colliding against it and coming to a complete stop.

I’ve tried playing with the physics and collision settings a bit, and using convex and smoothSphereCollisions on my rigidbodies, but the player continues to come to a stop even when just grazing the wall. I suspect I’ll need to implement some sort of custom collision handling, using Collision.contacts to find the contact points when a collision occurs, and then apply a translation along x for the player object.

I can’t help but think there’s a simpler way. Could anyone point me in the right direction?

Thanks,
-Juanelo

Maybe use a bouncy material instead and let it bounce instead of just hitting the wall and stuck there.

Thanks Zine,
I hadn’t thought of that! I’ve got some tweaking to do, but that seems to be a very good start!

best regards,
-Juan

Hmmm, left this alone for a while and came back to it.

Playing with the material settings got me closer to the end effect I was looking for, however, even after extensive testing, I’m pretty sure it won’t get me all the way there. There are simply to many wacky physics “side effects” where the vehicle tries to turn/flip, etc. Ideally the car should never “climb” the suface, but stay on the path.

Some time ago I was playing with the idea of implementing my own “hacked” physics where I would sample the collision info and apply it “manually” – is there a simpler alternative?

Here is a little more info:
http://forum.unity3d.com/threads/90420-transform-rotation-force-into-translation-force?highlight=juanelo

You could lock certain axes’ rotation and position of the rigidbody during the collision.

Hi Rab,
I know it’s been a while, but how could you go about this? I mean, locking only during the collision?

Thanks,
-Juanelo

It is a setting on the rigidbody. I’m not sure if the effect would be pretty when turning it off and on just during collisions though. Still, you might constrain a parent object full time? It is a setup that needs some tinkering to see what works.