Home>

Nice to meet you.
Currently using the SkyCar model in Unity's StandarddAsset
If there is an object (for example, a car other than the player) ahead, I would like to make it so that it stops before the player hits the vehicle, but I'm worried about it.
I imagine the image is like an eyesight, but is there any good way to do it?

  • Answer # 1

    Use

    Physics.Raycast.
    Just like Eyesight, it is a function that checks for an object that hits an invisible ray.
    Physics.Raycast-Unity Script Reference
    Raycast sample


    Please also see here.
    Tips for asking questions | StackOverflow