I am pretty new to unity and I am trying to do a wipeout style race but dont really know what to do with scripting as I am a bit of a newbie. I have looked at other posts with similar requests, however for my game I want the racing cars to stick to the track as I have a section where the track takes you upside down and into a tube, I have give it basic controls but they dont feel right, as soon as I turn it seems to spin out of control. I have used the racing tutrial for my script but I am not using wheels, also unity crashes everytime I get to the AI part of the tutorail so I dont know what is happening there as my pc is fine with most things, Maya 3DS Max etc.
I know this is alot to ask but any help would be great for scripting, here is my script so far…
var speed = 10.0;
var rotateSpeed = 3.0;
function Update ()
{
var controller : CharacterController = GetComponent(CharacterController);
transform.Rotate(0, Input.GetAxis (“Horizontal”) * rotateSpeed, 0);
var forward = transform.TransformDirection(Vector3.forward);
var curSpeed = speed * Input.GetAxis (“Vertical”);
controller.SimpleMove(forward * curSpeed);
} @script RequireComponent(CharacterController)
Sorry about being such a newbie its basically scripting, probably some more stuff aswell that I need helping with.
Your game doesn’t want to load on my pc, but after a quick check of the code, it looks like soemthing is wrong. In fact, with transform.Rotate you are adding a rotation to the actual one: when you relase the Left or Right key, the ship will continue to spin because your rotation never fades out.
I suggest to use rigidbodies instead of direct controls. I managed to get something interesting with that, but the main problem is getting the ship sticked to the track. It’s quite difficult and I don’t find any script that can handle that directly.
Sorry but I’m not an expert, so I can’t help you very much!
Anyway you should disable kinematic if you want to use a good physics!
Then you will have to change the controls to Rigidbody.addRelativeForce and rigidbody.addRelativeTorque in order to move it.
Assets/Smooth Camera.js(42,38): BCW0012: WARNING: ‘UnityEngine.Quaternion.EulerAngles(float, float, float)’ is obsolete. Use Quaternion.Euler instead. This function was deprecated because it uses radians instad of degrees.
But when I change it to quaternion.euler it doesnt work.