|
I have a gun shooting RayCasts. I would like to have 2d bullet textures shooting off from the gun, following the rays, to simulate the bullets being fired. How would i go about doing this? I have the ray instintate a bullet hole prefab when it collides with a collider, how can i make this not fill up my hierarchy with clones? I have heard about using decals for this prpose, but cannot figure out how to do that. Thanks!
(comments are locked)
|
|
There are many ways to make bullets follow a ray based on the desired behavior:
Then when the particles collide with stuff, you can get the particle's collider transform from the OnCollisionEnter handler and spawn your decal for the bullet hole to paste it on the object.
Now, to not fill up your hierarchy view with bullet decal instances, simply create a parent game object in your scene and call it "Bullet Holes". Then every time you instantiate a new bullet hole, make the "Bullet Holes" object the parent to that bullet hole object so in your scene you will only see the parent object unless you expand the view to see the bullet hole decals. I recommend you just preallocate one fixed bullet hole queue once on game startup and then cycle/reuse the bullet hole queue as new bullets hit things. Make the queue like 100 holes or something and then just keep cycling them. That way you aren't getting GC hitching from continuously creating new ones at runtime. ~hope that helps. gl
(comments are locked)
|
