- Home /
How to shoot particle bullets!!!
I've been searching around and cant find something that actually works. I'm creating a top-down shooter and all i want to do is to shoot particles...i already have a shoot script that instantiates and object when the fire button is pressed...i tried created a particle system, puting it inside a prefab and using the script to instantiate but when the fire button is pressed, the particles don't shoot like bullets, seems like they float there...here is the code i have so far:
I am also aiming towards having 3 bullets being shot at once...hence the "for" loop...
var speed : int; var cratePrefab:Transform; var bullNum : int;
function Update()
{
if(Input.GetButtonDown("Fire1"))
{
if(Collisions.GRENADE_AMMO > 0)
{
Collisions.GRENADE_AMMO -= 1;
for (var i=0; i<3 ; i++)
{
//GameObject.Find("g_count").guiText.text=""+Collisions.GRENADE_AMMO;
var crate = Instantiate(cratePrefab,GameObject.Find("shootpoint").transform.position,Quaternion.identity);
crate.rigidbody.velocity = transform.forward * speed;
}
}
}
}
Answer by 3dDude · Oct 25, 2010 at 08:25 PM
you could change the random force on the particleEmmiter to get a shotgun effect
Answer by brian 1 · Oct 25, 2010 at 07:27 PM
I found a way of getting it to shoot. I unchecked the "Simulate in Worldspace". That was easy, but now im trying to have the particles spit into 3 when the player shoots...like a shotgun effect...
Is there a way of doing so by messing around with the particle settings...or can i expand the script i have so far? If so , please somebody help
Answer by DougWiiBoy · Oct 25, 2010 at 10:49 PM
Not sure if this will work, but like 3dDude said, make all the little particles start in one spot, max and min particles of 3, then use random force to make them explode.
Your answer
Follow this Question
Related Questions
Mobile magic bullet 0 Answers
how to have bullets produce particles? 2 Answers
Best way to make bullets? 2 Answers
Rigidbody - bullets becomes bullethole image 0 Answers
Stopping a bullet but letting the animation continue 2 Answers