Graphics Reference
In-Depth Information
// this is just a 'default' function that (if needs be) should
// be overridden in the glue code
horizontal_input= default_input.GetHorizontal();
vertical_input= default_input.GetVertical();
}
public virtual void Update ()
{
UpdateShip ();
}
public virtual void UpdateShip ()
{
// don't do anything until Init() has been run
if(!didInit)
return;
// check to see if we're supposed to be controlling the player
// before moving it
if(!canControl)
return;
GetInput();
// calculate movement amounts for X and Z axis
moveXAmount = horizontal_input * Time.deltaTime * moveXSpeed;
moveZAmount = vertical_input * Time.deltaTime * moveZSpeed;
Vector3 tempRotation= myTransform.eulerAngles;
tempRotation.z= horizontal_input * -30f;
myTransform.eulerAngles=tempRotation;
// move our transform to its updated position
myTransform.localPosition += new Vector3(moveXAmount, 0,
moveZAmount);
// check the position to make sure that it is within boundaries
if (myTransform.localPosition.x <= -limitX || myTransform.
localPosition.x >= limitX)
{
thePos = Mathf.Clamp( myTransform.localPosition.x, -limitX,
limitX);
myTransform.localPosition = new Vector3(thePos, myTransform.
localPosition.y, myTransform.localPosition.z);
}
// we also check the Z position to make sure that it is within
// boundaries
if (myTransform.localPosition.z <= originZ || myTransform.
localPosition.z >= limitZ)
{
thePos = Mathf.Clamp( myTransform.localPosition.z, originZ,
limitZ);
myTransform.localPosition = new Vector3(myTransform.
localPosition.x, myTransform.localPosition.y, thePos);
}
}
}
Search WWH ::




Custom Search