// Update is called once per frame void Update() { if (previousPosition != transform.position) { velocity = (-1) * (previousPosition - transform.position); previousPosition = transform.position; } rb = GetComponent <Rigidbody2D>(); Velocity = rb.velocity; fov.SetOrigin(transform.position); fov.SetAimDirection(velocity); }
protected virtual void Update() { switch (state) { default: case State.Waiting: case State.Moving: HandleMovement(); FindTargetPlayer(); break; } if (fieldOfView != null) { fieldOfView.SetOrigin(transform.position); fieldOfView.SetAimDirection(GetAimDir()); } Debug.DrawLine(transform.position, transform.position + GetAimDir() * 10f); }