Quantcast
Channel: Latest Questions by TwitchBlade
Viewing all articles
Browse latest Browse all 6

how to find the child of an object i hit with raycast

$
0
0
Like the title says i need to find the children of an object i hit with a raycast so far i have float tempDist = 0f; float prevDist = 0f; foreach (Transform child in transform) { if(tempDist != null) { prevDist = tempDist; } tempDist = Vector3.Distance(hit.point, child.transform.position); if(tempDist > prevDist) { furthestAway = child.collider.name; } if(child.collider.name == "posXLock") { posX = child.transform.position; } else if(child.collider.name == "negXLock") { negX = child.transform.position; } else if(child.collider.name == "posZLock") { posZ = child.transform.position; } else if(child.collider.name == "negZLock") { negZ = child.transform.position; } } but that returns the object the script is on how do i make it do the one i hit with a raycast

Viewing all articles
Browse latest Browse all 6

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>