- Home /
Question by
william9518 · Aug 30, 2013 at 11:52 PM ·
raycastraycastingline drawingbullet marks
Raycast Bullet Tracer.
How would one make a Raycast bullet tracer? I have tried, but the tracer only appears if I hit something, as I used
if(Physics.Raycast(transform.position, transform.forward, Hit, maxDistance)){
With the Hit variable being a RaycastHit. But I want a tracer even if I don't hit something. I have tried using a temporary Vector3 storing the LineRenderer's second position parameter (The end of the line), like this:
var temp : Vector3 = gameObject.transform.position += new Vector3();
But this does not correspond with the rotation of the player. How can I do this?
Thanks in advance, William
Comment
Best Answer
Answer by robertbu · Aug 30, 2013 at 11:59 PM
You can simulate the hit by deciding on a distance. So the logic would look like:
var hitPos : Vector3;
if(Physics.Raycast(transform.position, transform.forward, hit, maxDistance)){
hitPos = hit.point.
}
else {
hitPos = transform.position + transform.forward * someDistance;
}
Where 'someDistance' is the distance you decided on to simulate a hit.