Hello, i’ve started a new project with a friend of mine.
the idea is that you play a rolling barrel.
I’ve got the barrel rolling and jumping, but i just can’t figure out how to let it move in air.
so that when i jump, i can still move a bit to left and right in air.
At this time, when i jump i’m not able to move once i’m in the air.
I’d like to be able to move in air with a counterbalance, so that if i jump right, i don’t instantly move left if i press A.
the script i have now:
#pragma strict
public var rotationSpeed = 100;
public var jumpHeight = 8;
public var walkSpeed = 3;
private var isFalling = false;
function Update ()
{
//Handle ball rotation.
var rotation : float = Input.GetAxis ("Horizontal") * rotationSpeed;
rotation *= Time.deltaTime;
GetComponent.<Rigidbody>().AddRelativeTorque (Vector3.up * rotation);
if (Input.GetKeyDown(KeyCode.Space) && isFalling == false)
{
GetComponent.<Rigidbody>().velocity.y = jumpHeight;
}
isFalling = true;
//if (Input.GetKeyDown(KeyCode.D) && isFalling == true)
//{
// GetComponent.<Rigidbody>().velocity.x = walkSpeed;
//}
}
function OnCollisionStay ()
{
isFalling = false;
}
I really hope someone can help me figure this out.
Thanks in advance!
Timo Leinders