Quantcast
Viewing all articles
Browse latest Browse all 97

using Raycast to detect collision

So i have an object im wanting to move till it reaches the object. I tried checking if the coordinates match but that didnt work. So i decided to use a raycast since the moving object is moving in one direction the whole time. The only problem im running into is that its telling me their colliding when they are no where near close. please help. RaycastHit hit = new RaycastHit(); Ray ray = new Ray(smokeMover.transform.position, -curVec.normalized); if (!Physics.Raycast(ray,out hit,1,-1) && hit.transform != nextRoot.gameObject.transform) { Debug.Log("NO COLLISON"); Debug.Log(hit.point); Debug.DrawLine(ray.origin, hit.point,Color.yellow); smokeMover.transform.position += curVec.normalized * Time.deltaTime * moverSpeed; } else { Debug.Log("COLLISON"); }

Viewing all articles
Browse latest Browse all 97

Trending Articles



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