public void Reset() { state = NeckbeardState.INACTIVE; gameObject.SetActive(false); deadTime = 0; lastDistance = Mathf.Infinity; this.tag = "NeckbeardAlive"; }
public void Send() { type = NeckbeardAIController.BehaviorType.PACING; transform.LookAt(moveTo); velocity.x = transform.forward.x; velocity.z = transform.forward.z; velocity.Normalize(); velocity *= SPEED; velocity.y = rigidbody.velocity.y; state = NeckbeardState.MOVETO; gameObject.SetActive(true); ragdoll.SendMessage("Running"); }
void OnTriggerEnter(Collider col) { if (state != NeckbeardState.INACTIVE && state != NeckbeardState.DEAD) { if (col.tag.Equals("Fly")) { hasFlies = true; if (!flies.Contains(col.gameObject)) { flies.Add(col.gameObject); } } else if (col.tag.Equals("HandP1") || col.tag.Equals("HandP2")) { state = NeckbeardState.DEAD; this.tag = "NeckbeardDead"; ragdoll.gameObject.SendMessage("RagTime"); } } }
// Update is called once per frame void Update() { if (state == NeckbeardState.MOVETO) { float distance = Vector3.Distance(transform.position, moveTo); if (distance > lastDistance) { velocity = Vector3.zero; state = NeckbeardState.ACTIVE; ragdoll.SendMessage("Standing"); } lastDistance = distance; } else if (state == NeckbeardState.DEAD) { deadTime += Time.deltaTime; if (deadTime > INACTIVE_TIME) { Reset(); } } }