Graphics Reference
In-Depth Information
// we are going to use the same id for this player and
// its weapons
id=racerID;
// tell weapon controller this id so we can add it to
// projectiles. This way, when a projectile hits something
// we can look up its id and trace it back to this player
weaponControl.SetOwner(id);
// set up a repeating invoke to update our position, rather
// than calling it every single tick or update
InvokeRepeating("UpdateBattlePosition",0, 0.5f);
}
public void UpdateBattlePosition()
{
// grab our score board position from the global battle
// manager
myBattlePosition=
GlobalBattleManager.Instance.GetPosition ( racerID );
}
public override void UpdatePhysics ()
{
if( canControl )
base.UpdatePhysics();
if( isFinished )
myBody.velocity *= 0.99f;
// if we are moving slow, apply some extra force to turn the
// car quickly so we can do donuts (!) - note that since there
// is no 'ground detect' it will apply it in the air, too (bad!)
if( mySpeed < TurnTorqueHelperMaxSpeed )
{
myBody.AddTorque( new Vector3( 0, steer * myBody.
mass * turnTorqueHelper * motor, 0 ) );
}
}
private float timedif;
public override void LateUpdate()
{
// get the state of the battle from the battle controller
isGameRunning= battleControl.battleRunning;
if( isGameRunning )
{
// check to see if we've crashed and are upside
// down/wrong(!)
Check_If_Car_Is_Flipped();
// make sure that gunControl has been told it can fire
if( isAIControlled )
gunControl.canControl=true;
// we check for input in LateUpdate because Unity
// recommends this
Search WWH ::




Custom Search