- Home /
Instantiate object and make it follow raycast
Hey, I'm trying to make bullet tracer for my game. And I can't really make it to work... What i currently have done is that you can shoot with your gun and it increase recoil and spread when you shoot. And everything here is being runned by a raycast. Now what I did was I created a sphere and added smoke particles. And what I did in the shoot script was thatit would instantiate this sphere when I shoot. It works good with a pistol but when it comes to an assault rifle: it will only instantiate the sphere forward and not being spread like the raycast.
After all complicated explanation : my question is that how to make an instantiate object follow the raycast. Like it instantiates on the direction my raycast is going... Hope you guys understood, thanks in advance :)
Answer by Prodigga · May 24, 2013 at 09:50 AM
From what I understand, you want the instantiated object to look in the direction that you shot? You already have the direction - that's how you fired the ray. Just use Quaternion.LookRotation to set the rotation of the instantiated object.