ray | El punto inicial y la dirección del rayo. |
maxDistance | La distancia máxima que el rayhit se le permite estar desde el inicio del rayo. |
layerMask | Un Layer mask que es utilizado para ignorar colliders selectivamente cuando se emita un rayo. |
queryTriggerInteraction | Especifica si esta consulta debería golpear Triggers. |
Emite un rayo a través de la escena y devuelve todos los golpes. Tenga en cuenta que el orden no está garantizado.
See Also: Raycast.
using UnityEngine; using System.Collections;
public class ExampleClass : MonoBehaviour { void Update() { RaycastHit[] hits; hits = Physics.RaycastAll(transform.position, transform.forward, 100.0F);
for (int i = 0; i < hits.Length; i++) { RaycastHit hit = hits[i]; Renderer rend = hit.transform.GetComponent<Renderer>(); if (rend) { // Change the material of all hit colliders // to use a transparent shader. rend.material.shader = Shader.Find("Transparent/Diffuse"); Color tempColor = rend.material.color; tempColor.a = 0.3F; rend.material.color = tempColor; } } } }
Notes: Raycasts will not detect colliders for which the raycast origin is inside the collider.
If you move colliders from scripting or by animation, there needs to be at
least one FixedUpdate executed so that the physics library can update it's data structures, before a Raycast will hit the collider at it's new position.
origin | El punto inicial del rayo en coordenadas del mundo. |
direction | La dirección del rayo. |
maxDistance | La distancia máxima que el rayhit se le permite estar desde el inicio del rayo. |
layermask | Un Layer mask que es utilizado para ignorar colliders selectivamente cuando se emita un rayo. |
queryTriggerInteraction | Especifica si esta consulta debería golpear Triggers. |
See Also: Raycast.
Mirar el ejemplo de arriba.