- Home /
Is there a way to draw particles on a raycast?
In my game one ability uses a raycast to determine where the shot hits. Is there any way to draw a trail along the raycast? Can I spawn particles along certain intervals on the raycast?
Are you talking for debug purposes or for actual in game purposes (for example, a laser)?
Answer by karljj1 · Mar 01, 2015 at 10:20 PM
Vector3.Lerp or Vector3.MoveTowards are what you want here. Take your current position and the point your ray hits and move towards it and instantiate an object at each step.
E.G
float step = 1f / numberOfObjectsIWant;
float currentStep = 0;
for( int i = 0; i < numberOfObjectsIWant; ++i )
{
currentStep += step;
Vector3 position = Vector.Lerp( whereIAm, whereMyRaycastHit, currentStep );
// Create object at position
}
I am trying to do the same thing! But, I am not much of a coder, I am more of a designer and have been using playmaker for VR. Could you guys help me at all with how I would do this, I am guessing I can not just drag and drop that code as a script?
Thanks!
Answer by khauschild · May 02, 2017 at 02:43 PM
I am trying to do the same thing! But, I am not much of a coder, I am more of a designer and have been using playmaker for VR. Could you guys help me at all with how I would do this, I am guessing I can not just drag and drop that code as a script?
Thanks!