Hey everyone,
Im very new to unity and am making a game for my senior studio class. I am traditionally a 3D modeler so I have very little knowledge of coding in any language. My problem is that I have a motorcycle model in the engine and I can move around fine but when I go up a ramp or any none flat object the motorcycle doesnt react to the changing terrain. Iv tried messing around with rigid body stuff but I really have no clue what Im doing. Is there a simple way to add some type of collision to both wheels instead of the single character controller? Thanks in advance and sorry for such a easy question I guess.
Have all the scenery objects (ramps, etc) attached colliders.? When you import a mesh for scenery you must check “generate colliders” in order to get collisions (with your motorcycle).
collision isnt necessarily the problem. What I need is for, when going up a steep ramp, I need the motorcycle to angle itself with the direction of the surface. Right now when I drive up a steep ramp my motorcycle stays flat. The character controller Im using is whats colliding with the surfaces so I guess I somehow need two collider surfaces on the motorcycle. (side not: currently Im using a fill in bike until our final assets are completed so the motorcycle for now is one single blockout object instead of having two independent wheels. Not sure if that information was needed)
Yes, you need to use wheel colliders like in a car…
Update:
So now I have two wheel colliders attached to the bike. When I test the scene and try to go up a simple inclined plane the bike starts flipping and going through the plane I created. Is there a setting to make the model (or wheel colliders) stay on the ground?
A couple of notes:
- Make sure your wheel colliders are oriented down at the ground. In the editor, they have a little line in the circle - it should be straight towards the ground, on the bottom half of the circle.
- You may want to set your rigidbody’s centerOfMass low, e.g:
rigidbody.centerOfMass = new Vector3(0, -1f, 0);
- You also may need additional colliders within the bike to represent its body. Otherwise, the bike will still go through colliders that aren’t on the ground (like walls).
OMG mklaurence you just solved my problem thank you very much!