Hello, I’m a newcomer to Unity and scripting in general. Currently I’m using Java for all my scripting ATM. The game is 3D and the main player is a sphere that moves forward, back, left, right and double jumps. I’ve run into a problem with this as because it’s a sphere if I lets say move forward then left at the same time the ball rotates putting it’s whole movement off. Here’s the script I used to program the main player
#pragma strict
var rotationSpeed = 100;
var JumpHeight = 8;
private var isFalling = false;
function Update ()
{
var rotation : float = Input.GetAxisRaw (“Horizontal”) * rotationSpeed;
rotation *= Time.deltaTime;
GetComponent.().AddRelativeTorque (Vector3.back * rotation);
if (Input.GetKeyDown(KeyCode.Space) && isFalling == false)
{
GetComponent.().velocity.y = JumpHeight;
isFalling = true;
}
{
var brotation : float = Input.GetAxisRaw (“Vertical”) * rotationSpeed;
brotation *= Time.deltaTime;
GetComponent.().AddRelativeTorque (Vector3.right * brotation);
}
}
function OnCollisionStay ()
{
isFalling = false;
}
Anybody have any ideas?