As you can tell, my movement script isn’t working to well, I need a bit of help with this, I am currently using a box collider to keep it upright, as you can clearly see - it’s not working.
I need a few tips to getting this right, I’ve never been good with movement.
My code;
#pragma strict
var anim : Animation;
var moveSpeed : int;
var jumpHeight : int;
var gravity : int;
private var curSpeed : float;
private var cont : CharacterController;
private var moveDir : Vector3;
function Start()
{
curSpeed = moveSpeed;
cont = gameObject.GetComponent(CharacterController);
}
function Update ()
{
anim = GetComponent.<Animation>();
moveDir = Vector3(Input.GetAxis("Horizontal"),0,Input.GetAxis("Vertical"));
moveDir = transform.TransformDirection(moveDir);
moveDir *= curSpeed;
if(Input.GetButtonDown("Jump"))
{
moveDir.y = jumpHeight;
}
cont.Move(moveDir * Time.deltaTime);
moveDir.y -= gravity * Time.deltaTime;
}
I appreciate any help that you give! Thanks (: