how to check the distance between ray hit point and any game object in the game.

i am new to ray casting so any help with the code will be appreciated.
in the screenshot given below … when i click on any chair the character goes to that chair, and i want to measure the distance between the hit point and the character moving towards the hit point.

70898-sss.png

The StartCoroutine() call should only be called once, not every frame (for example in Start() or Awake()). You could also call it once in the Update() method as soon as some condition is met and you want your door to start rotating. This is similar to the way you probably did it in JS, except that in C# we have to explicitly define the return type to be an IEnumerator if we want to yield return within a while loop.

1 Answer

1

Vector3.Distance(player.position, chair.position);