private IEnumerator IdleBehaviour() { float walkTimer = PartolDuration; int direction = 1; while (true) { if (AlertValue >= 1) { ChangeState(AIState.Alert); } if (Partol) { character.Move(Vector3.right * direction, false); walkTimer -= Time.deltaTime; if (walkTimer <= 0) { walkTimer = PartolDuration; direction *= -1; yield return(new WaitForSeconds(2)); } } yield return(null); } }
public override void ActionUpdate(AI_Base brain, Character_Base character) { base.ActionUpdate(brain, character); ResetPathTimer += Time.deltaTime; if (ResetPathTimer >= ResetTimerDuration) { ResetPathTimer = 0; agent.CalculatePath(TargetPosition, path); } foreach (Vector3 p in path.corners) { Debug.DrawLine(p, p + Vector3.up * 5, Color.red, 0.2f); } if (path.corners.Length >= 2) { character.Move(path.corners[1] - character.transform.position); if (Vector3.Distance(character.transform.position, path.corners[1]) <= 0.1f) { agent.CalculatePath(TargetPosition, path); } } else { ActionFinish(); } if (Vector3.Distance(character.transform.position, TargetPosition) <= Distance) { ActionFinish(); } }
private void Update() { Vector3 InputDirection = Vector3.forward; InputDirection.Set(Input.GetAxisRaw("Horizontal"), 0, Input.GetAxisRaw("Vertical")); character.Move(InputDirection); if (Input.GetKeyDown(KeyCode.Space)) { character.Jump(); } if (Input.GetMouseButtonDown(0)) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit, 100000, GroundLayer)) { if (hit.collider) { character.AttackCommand(hit.point - character.transform.position); } } } }
private void Update() { Vector3 InputDirection = Vector3.forward; InputDirection.Set(Input.GetAxisRaw("Horizontal"), 0, Input.GetAxisRaw("Vertical")); character.Move(InputDirection); }
public override void ActionUpdate(AI_Base brain, Character_Base character) { base.ActionUpdate(brain, character); character.Move(TargetPosition - character.transform.position); if (Vector3.Distance(character.transform.position, TargetPosition) <= Distance) { ActionFinish(); } }
public override void ActionUpdate(AI_Base brain, Character_Base character) { base.ActionUpdate(brain, character); if (character.canAttack()) { GameObject g = FindNearestEnemy(); if (g != null) { character.AttackCommand(g.transform.position - Character.transform.position); } } if (FollowTransform != null) { character.Move(FollowTransform.position - character.transform.position); } else { character.Move(Vector3.zero); } }
public override void ActionUpdate(AI_Base brain, Character_Base character) { base.ActionUpdate(brain, character); Vector3 TargetPosition = Path[WaypointIndex]; character.Move(TargetPosition - character.transform.position); if (Vector3.Distance(character.transform.position, TargetPosition) <= 1) { WaypointIndex++; if (WaypointIndex >= Path.Length) { ActionFinish(); } } }
public override void ActionUpdate(AI_Base brain, Character_Base character) { base.ActionUpdate(brain, character); if (Target == null) { ActionFinish(); } Vector3 Direction = Target.transform.position - Character.transform.position; if (Direction.magnitude <= StopRange) { character.Move(Vector3.zero); if (timer <= 0) { ActionFinish(); } } else { Character.Move(Direction.normalized); } timer -= Time.deltaTime; }