https://www.youtube.com/watch?v=Mj5p-BOWvqs
Apparently instead of the rotation being from 0-360, it's 0-1 with 1 being 180.
public var gsp : float;
public var maxGsp : float;
public var acc : float;
public var frc : float;
public var cam : GameObject;
public var camRot : float;
function FixedUpdate () {
if(Input.GetAxis ("Vertical")>0 || Input.GetAxis ("Horizontal")>0 )
{
gsp += acc;
}
else if(Input.GetAxis ("Vertical")<0 || Input.GetAxis ("Horizontal")<0 )
{
gsp += acc;
}
else
{
gsp -= frc;
}
if(gsp >= maxGsp)
{
gsp = maxGsp;
}
else if(gsp <= 0)
{
gsp = 0;
}
moveSp.z = (Input.GetAxis ("Vertical") * gsp / 12);
moveSp.x = (Input.GetAxis ("Horizontal") * gsp / 12);
//transform.localPosition.z += moveSp.z;
//transform.localPosition.x += moveSp.x;
transform.Translate(moveSp.x * Mathf.Cos(camRot) , 0 , moveSp.z * Mathf.Cos(camRot));
} //Movement Rules
}
function LateUpdate () {
if(gsp != 0)
{
transform.rotation.y = cam.transform.rotation.y;
}
}
↧