What if use a "water" tag so that the water layer is not show a cursor

A bit of query if the following proposed alternative approach is fine or not:
, so we can only add this “hitObj.transform.tag == “Water”” so that the water layer is not showing the walking cursor. Additioanlly, adding a maxRayDistance so the player cann’t go too far.
Thank you in advance.

        private bool InteractWithMover()
        {
            Ray ray = GetMouseRay();
            bool hasHit = Physics.Raycast(ray, out hitObj, maxRayDistance);

            if (hasHit)
            {
                if (hitObj.transform.tag == "Water")
                {
                    return false;
                }
                if (!Input.GetMouseButton(1) && Input.GetMouseButton(0))
                {
                    GetComponent<Mover>().StartMoveAction(hitObj.point, playerNormalSpeedFraction);
                }
                SetCurser(CursorType.Movement);
                return true; 
            }
            return false;
        }

Water may not be the only obstacle to walking to a location. Using this model, I would still have a walking cursor while it is hovering over a building, for example. Raycasting to the NavMesh ensures we can really get to the location.

As always, thank you for your prompt reply and clarification.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms