Hi there, my game I’m working has a character viewd through a camera looking down at a 45 degree angle. The Character is meant to move on all 8 axis and transform his rotation in each direction. I was able to figure out how to make all the transformations and give velocity to the character in the facing direction. However the transition between directions is instantaneous and looks very bad. I’d like it to be slowed down a bit and smooth.
Here is the current Script that cause movement:
var Speed : float = 2;
function Update ()
{
if(Input.GetKey("w") && !Input.GetKey("a") && !Input.GetKey("d"))
{
rigidbody.velocity = Vector3(0,0,1) * Speed;
transform.eulerAngles = Vector3(0,0,0);
}
if(Input.GetKey("w") && Input.GetKey("a"))
{
rigidbody.velocity = Vector3(-1,0,1) * Speed;
transform.eulerAngles = Vector3(0,-45,0);
}
if(Input.GetKey("w") && Input.GetKey("d"))
{
rigidbody.velocity = Vector3(1,0,1) * Speed;
transform.eulerAngles = Vector3(0,45,0);
}
if(Input.GetKey("s") && !Input.GetKey("a") && !Input.GetKey("d"))
{
rigidbody.velocity = Vector3(0,0,-1) * Speed;
transform.eulerAngles = Vector3(0,-180,0);
}
if(Input.GetKey("s") && Input.GetKey("a"))
{
rigidbody.velocity = Vector3(-1,0,-1) * Speed;
transform.eulerAngles = Vector3(0,45,0);
}
if(Input.GetKey("s") && Input.GetKey("d"))
{
rigidbody.velocity = Vector3(1,0,-1) * Speed;
transform.eulerAngles = Vector3(0,-45,0);
}
if(Input.GetKey("a") && !Input.GetKey("w") && !Input.GetKey("s"))
{
rigidbody.velocity = Vector3(-1,0,0) * Speed;
transform.eulerAngles = Vector3(0,-90,0);
}
if(Input.GetKey("d") && !Input.GetKey("w") && !Input.GetKey("s"))
{
rigidbody.velocity = Vector3(1,0,0) * Speed;
transform.eulerAngles = Vector3(0,90,0);
}
From here I am unsure what to do. So any help would be appreciated :D!