/// <summary> /// Move the marker so that it highlights the place where the mouse points to the ground. /// </summary> /// <param name="e">A MouseGroundEvent</param> private void Move(CustomEvent e) { Debug.Assert(e.GetType() == typeof(MouseGroundEvent), "Non-MouseGroundEvent in Move()"); MouseGroundEvent groundEvent = e as MouseGroundEvent; loc.x = groundEvent.groundPos.x; loc.z = groundEvent.groundPos.z; rb.MovePosition(loc); }
/// <summary> /// Move the main character so that they are hovering over a point on the ground the player is pointing at /// with the mouse. /// </summary> /// <param name="e">A MouseGroundEvent with the point on the ground where the player is pointing.</param> private void Move(CustomEvent e) { Debug.Assert(e.GetType() == typeof(MouseGroundEvent), "Non-MouseGroundEvent in Move()"); MouseGroundEvent groundEvent = e as MouseGroundEvent; playerGroundLoc.x = transform.position.x; playerGroundLoc.z = transform.position.z; Debug.DrawLine(transform.position, playerGroundLoc, Color.red, 3.0f); groundMoveDir = (groundEvent.groundPos - playerGroundLoc).normalized; moveMagnitude = Vector3.Distance(groundEvent.groundPos, playerGroundLoc); totalGroundMove = groundMoveDir * moveMagnitude * speed; rb.MovePosition(transform.position + totalGroundMove); }