// Update is called once per frame void FixedUpdate() { if (updateTimer.TryUpdateThisTick()) { CliffSensors(); } }
//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); }
// Update is called once per frame void FixedUpdate() { if (updateTimer.TryUpdateThisTick()) { DoFixedUpdate(); } }