コード例 #1
0
 // Update is called once per frame
 void FixedUpdate()
 {
     if (updateTimer.TryUpdateThisTick())
     {
         CliffSensors();
     }
 }
コード例 #2
0
 //Note, will only actually on frames where LOSUpdateTimer expires, or if there
 //was previously a target in LOS.
 public bool IsGameobjectInLOS(GameObject gameObject)
 {
     if (LOSUpdateTimer.TryUpdateThisTick() || targetInLOS)
     {
         RaycastHit hit;
         Vector3    rayDirection = gameObject.transform.position - body.position;
         Debug.DrawRay(body.position, rayDirection, Color.green);
         if (Physics.Raycast(body.position, rayDirection, out hit))
         {
             if (hit.transform == gameObject.transform)
             {
                 print("Player in los");
                 targetInLOS = true;
             }
             else
             {
                 print("Raycast hit, not target");
                 targetInLOS = false;
             }
         }
         else
         {
             print("No raycast hit");
             targetInLOS = false;
         }
     }
     return(targetInLOS);
 }
コード例 #3
0
 // Update is called once per frame
 void FixedUpdate()
 {
     if (updateTimer.TryUpdateThisTick())
     {
         DoFixedUpdate();
     }
 }