public override void Act(GameObject player, GameObject npc) { if (Vector3.Distance(npc.transform.position, destination) <= 0.2f) { FindNextPoint(); } Vector2 velocity = aiMovement.CalculateVelocity(); aiMovement.Move(velocity * Time.deltaTime); aiMovement.SetDirection(destination); }
public override void Act(GameObject player, GameObject npc) { Vector2 velocity = aiMovement.CalculateVelocity(); aiMovement.Move(velocity * Time.deltaTime); if (aiMovement.collisions.touchedPlayerHorizontally) { npc.GetComponent <NPCController>().animator.SetTrigger("TouchPlayerHorizontally"); } aiMovement.SetDirection(player.transform.position); }
public override void Act(GameObject player, GameObject npc) { if (timeBetweenJumpsLeft <= 0f && aiMovement.collisions.below) { if (turnOnNextJump) { aiMovement.DirectionX = -aiMovement.DirectionX; turnOnNextJump = false; } timeBetweenJumpsLeft = timeBetweenJumps; velocity = aiMovement.CalculateJumpVelocity(); velocity = aiMovement.CalculateVelocity(); aiMovement.Move(velocity * Time.deltaTime); } else if (timeBetweenJumpsLeft >= 0f && aiMovement.collisions.below) { timeBetweenJumpsLeft -= Time.deltaTime; aiMovement.SimulateGravity(); } else if (!aiMovement.collisions.below) { velocity = aiMovement.CalculateVelocity(); aiMovement.Move(velocity * Time.deltaTime); } if (aiMovement.collisions.left || aiMovement.collisions.right) { turnOnNextJump = true; } if (aiMovement.collisions.touchedPlayerHorizontally) { player.GetComponent <Player>().HandleHit(100f); } }