|
I'm trying to use a wheel collider in a school project and was wondering A)how to script it to work with Input.GetKey() with the up arrow increasing the motorTorque.B)will it react with the terrain object moving the bike forward?? Any answers would be appreciated.
(comments are locked)
|
|
Wheel colliders aren't easy things to control, when making a bike or motor you'll have to do some tricks to make it stable (not falling) as the wheel collider is infinitely thin. Below I wrote a simple motor script (that doesn't solve the falling over problem, but set y of centerOfMass property to negative values does help). Because the wheelcolliders shouldn't rotate with the wheels, you need to set up the motor as follows for the script, the motor has two wheel attach gameobjects (frontwheelattach and backwheelattach), you must add the wheelcolliders to these nodes (and attach these to the script properties front/backWheelCollider). The attach nodes must have the actual wheels attached, and these should be connected to the script front/backWheelTransform. If you need a demo project to see how to setup the script I could make something quick for that as well, just let me know. thanks a lot, i put it in my project and assigned the wheel colliders for the front and back wheel but everytime i run it the wheels move to the center of the bike. Any suggestions?
Mar 22 at 03:50 PM
JDubs212
i've also got a problem with changing the motorPower using keyboard input
Mar 22 at 11:41 PM
JDubs212
I had the same problem with the wheels moving to the center of my vehicle. First I found that when my vehicle came to a rest the collider.GetGroundHit function would return false and I also noticed that (localPosition = -Vector3.up * collider.suspensionDistance;) would set the local postion to (0,-suspensionDistance,0) which would be the pivot point of the parent object in most cases the center of the vehicle. Any body know why the GroundHit would return false just because the collider is at rest?
Sep 16 at 02:18 PM
Kevin Ambruster
(comments are locked)
|
Unity Answers has moved to a new system, and some users may have trouble logging in.