get array of RaycastAll hits
Hey! I wanna get a list of all hits that my RaycastAll gets. so far i tried this:
public GameObject[] rayhits;
RaycastHit closestValidHit = new RaycastHit();
RaycastHit[] hits = Physics.RaycastAll(transform.position, transform.forward, 100.0F, layers);
for (int i = 0;i < hits.Length;i++) {
GameObject rayhits = hits [i].collider.gameObject;
}
but that doesent give me any result somehow?
The syntax is correct so the problem has to lie in the raycasting itself, i.e. range too short, no colliders of the same layer in the path of the ray, or something else.
i set the layer to everything and the object is surrounded by colliders that should get hit
Answer by RealSoftGames · Oct 02, 2016 at 05:16 PM
do you have rigidbody on the objects you want to raycast against. even if they are set to kinematic
?? But that shouldn't matter. A raycast only cares about colliders. $$anonymous$$aybe you're thinking of OnTriggerEnter?
Your answer
Follow this Question
Related Questions
Raycast is hitting a collider but ignores it right after 0 Answers
How can i detect 2 raycasthit2D in the same function storing their Vector2 position? 0 Answers
How Can I Detect Objets on Click with Raycast? 0 Answers
RaycastHit.normal and Vector3.reflect problem 0 Answers
Check if position is inside a collider 5 Answers