示例#1
0
        void Start()
        {
            //actual important start stuff
            ship = gameObject.GetComponent <Mothership>();

            //placeholder control stuff
            Debug.Log("Initializing pilot");
        }
示例#2
0
		void UpdateSensors()
		{
			if(target == null)
			{
				Debug.Log("{0} Target lost", gameObject);
				if(!LockTarget())
				{
					Debug.Log("Target not found");
					return;
				}
			}
			//Obtain reference to own Mothership for repeated use
			Mothership ship = gameObject.GetComponent<Mothership>();
			
			//Relative position to enemy agent (Cartesian)
			Vector3 rposCart = ownTransform.InverseTransformPoint(tgtTransform.position);
			
			//Relative velocity to enemy agent (Cartesian)
			Vector3 rvelCart = ownTransform.InverseTransformVector(target.GetComponent<Rigidbody>().velocity - gameObject.GetComponent<Rigidbody>().velocity);
			
			//Convert rpos and rvel to spherical
			Vector3[] rel = Util.PosVelCartToSphr(rposCart, rvelCart);
			rpos = rel[0];
			rvel = rel[1];
			
			//Hitpoints of enemy agent as fraction of total
			enemyHP = target.GetComponent<Mothership>().hitpoints / target.GetComponent<Mothership>().maxHitpoints;
			
			//Own angular velocity
			angVel = gameObject.GetComponent<Rigidbody>().angularVelocity;
			
			//Own hitpoints as fraction of total
			ownHP = ship.hitpoints / ship.maxHitpoints;
			
			//Weapon muzzle velocity
			muzzleVel = ship.muzzleVelocity;
			
			//Weapon time until next shot as fraction of total reload time
			reloadFraction = (float)ship.lastFire / ship.framesPerShot;
			
			//Weapon ready state
			fireReady = ship.lastFire == 0;
			
			dirty = false;
		}