void ChaseTarget() { if (GrubTarget != null) { moveComponent.RotateTowards(GrubTarget.position); } else { moveComponent.RotateTowards(PlayerTarget.position); } }
void Update() { if (!IsGrounded()) { return; } movementComponent.RotateTowards(player.transform.position); movementComponent.SetTraverse(transform.forward); }
private void HandleRotate() { // Arbitrary plane instead of actual field GameObject because intersections // have to be valid -inf < x,z < inf. Ray screenToPointRay = GameCamera.Get().GetScreenToPointRay(Input.mousePosition); if (!groundPlane.Raycast(screenToPointRay, out float intersectAt)) { return; } Vector3 positionOnPlane = screenToPointRay.GetPoint(intersectAt); movementComponent.RotateTowards(positionOnPlane); }
protected void RunAway(bool special = false) { if (gameObject.activeSelf == true) { if (special) { baseSprite.color = ColorList.colors[(int)ColorNames.Yellow]; gameObject.layer = 16; // Special Escape. } else { polyCollider.enabled = false; } animating = true; StopCoroutine(movementRoutine); Vector3 direction = transform.position - Vector3.zero; moveComponent.RotateTowards(-direction); moveComponent.MoveSpeed += 3; } }