Unity
RayCast(QueryTriggerInteraction)
JiHxxn
2024. 3. 16. 15:29
📜 information
- 충돌하도록 적용 (Collide)
private void CheckCollisions(float moveDistance)
{
Ray ray = new Ray(transform.position, transform.forward);
RaycastHit hit;
if(Physics.Raycast(ray, out hit, moveDistance, collisionMask, QueryTriggerInteraction.Collide))
{
OngitObject(hit);
}
}
void OngitObject(RaycastHit hit)
{
Destroy(gameObject);
}