Jump to content
This site uses cookies! Learn More

This site uses cookies!

armedunity.com uses cookies to improve user experience.

By continuing to use this site, you agree to allow us to store cookies on your computer.

  • 0
Aeleas

Gun with barrels shoot one bullet !!

Question

 

8366a9d5885d289bb1d3055b1da80aa2.jpg

 

I'm working on gun with 3 barrels, the bullet position setup near every barrels but i can see only one work ! one of the three bullet position release bullet. the other two not release any bullets and there is no error !!

Also, if you could make the bullets goes not in the same time will be very good.

 

Please login or register to see this code.

 

Share this post


Link to post
Share on other sites

6 answers to this question

Recommended Posts

  • 1

Hi, how can you fire 3 bullets, when you instantiate only one bullet?
GameObject fire = Instantiate(prefab) as GameObject;
and then you move this bullet 3 times.

 

 

try:

Please login or register to see this code.

 

  • Like 1

Share this post


Link to post
Share on other sites
  • 0

As said OMA, you created one instantiation which you named Fire, you changed three times its position and you applied a force. Of course, there is no error, but no logic too...

If you prefer, but it's no really optimized, you can repeat three times the same code. Loop is always better :

Please login or register to see this code.

 

  • Like 1

Share this post


Link to post
Share on other sites
  • 0

Thank you so much. When i post this topic, I was thinking on geckoo script method to allow me to add timer. So, every bullet will not be release at the same time. 

Now I'm using OMA script. Now it works, but 3 bullets goes out from the barrels in the same time. How to fix this ? How to add time between every bullet to delay the release ?

Share this post


Link to post
Share on other sites
  • 0

* move "for loop" out of Update()
* add yield return new WaitForSeconds(waitTime) in for loop.
* use bool to check if you can fire.

  • Like 1

Share this post


Link to post
Share on other sites
  • 0

This is another question, but personally I use always a Coroutine WaitForSecond so as to set a firerate for a gun or something else.

In my project Abaddon, I used it this way. Maybe it could be helpful for you. Take a look at code below :

Please login or register to see this code.

 

 

 

  • Like 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×