W
W
wf_egor2020-12-08 23:24:00
Unity
wf_egor, 2020-12-08 23:24:00

How to make RayCast from an object in a unit?

Hello! I'm creating a game, I need to make the enemy see the player. For this I chose Raycast. I can't make the ray shoot from an object (public GameObject posToRay). How to do it so that the script is on one object and the beam comes out of the posToRay object. Thanks in advance! If necessary, I will describe more clearly.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
freeExec, 2020-12-09
@freeExec

The ray comes out from any coordinates you specify. Though this object, though another, even the "center of the universe."
Physics.Raycast(posToRay.transform.position, ...)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question