Car in Tunnel [Solved]

dinvog

24-03-2007 06:41:03

Hey,
I am creating a small game application which consists of only tunnels/tubes and no gravity. So the car models are free to roam inside the tunnel. However I wanted the car to always be in contact with the surface. I removed gravity and I have tried a variety of things.

I tried to make the tunnel a magnet and the car magnetic. But the car shows erratic behaviour as it oscillates. And it stays in the middle of the tunnel.

I thnen tried to use a material but realised that meshShape does not have the parameter and using a such a material on the car does not have the desired effect.

I then tried to use a combinatin of angular damping, add force and freeze rotation.No luck there either :?

I now am tring to figure out a way to find the contact point between the two meshes and add a force to its normal so the car always sticks. I was looking up the contact pair procedure to see if it gathers information about the contact point.

Any better ideas?

jchmack

24-03-2007 13:37:17

Try making the car a magnet and the tunnel magnetic (instead of vice versa) with Anisotropic friction. Leave gravity on if you want a waterslide type effect. But if you want a racing game im betting you want it off so your cars dont bunch up.

dinvog

24-03-2007 17:53:34

Yeah I tried that as well, but the model/car seems to be stuck in the middle of the tube and the car oscillates traveling inside / outside the tunnel.
I also get a warning in the physics log about the body being kinematic.

I did have a closer look at the mesh and notice that the surface is made up of triangles giving the tunnel a spiral effect mesh, maybe that is why the model oscillates.

Will try some parameters given in the exporter

jchmack

25-03-2007 13:57:14

im not too familiar with the magnet features but is there a way to turn down the distance that a magnet can effect you car? So that whatever part of the tunnel the car is closest to will be the only thing attracting it. This way you could just set that distance to (or probably less than) the radius of your tunnel.

betajaen

25-03-2007 14:05:30

I think the magnet idea is a little overkill, but you can do something quite similar.

Raycast "downwards", and get the nearest triangle and normal. Invert the normal (so it faces in the opposite direction), then multiply it by how much force you want to pin the car to the tunnel.

Then apply the force directly to the car.

dinvog

25-03-2007 16:46:31

Yeah I was thinking along those lines as well but I realised there was a far easier way to implement the effect. I did have to compromise on the type of collision model I could use though.

The earlier model I was using was a capsule and that turning on its axis so the orientation kept changing. So I used a square mesh with a circular plate at bottom, now it does not turn on it's axis and so I can apply the localforce procedure and so it always sticks to the tunnel. It works beautifully :) .

Now on to other things. I will be back ... with more questions. Thanks again for all the help