Here is my code. What is does is sprays endless ammounts of bullets (alot per frame). I do not know how to fix it. I have been to countless places, and needless to say no one has answered it to which i can find the answer. Thanks for your help :)
(comments are locked)
|
|
2 ways either you use GetButtonDown and you need to press each time or use a timer: first way second way is shooting every 2 seconds as you keep the button down: By the way you don't need to yield and destroy. The second argument passed to the destroy function is a timer. This was what i was looking for. There is the fixed Destroy () command and the Time.time value would be sufficiant to use instead of overloaded functions on one script. YOU NEED TO FIX YOUR SPACES AND TABS! This is kinda illegible. As i see it, var timeing:int; is a function and function Update() is a if and if is a if and if is another if and then you have to look were the }'s end. I will show you a correct Version that makes sence, not to doubt you know a lot more than i do. It might just take me a shorter time to learn it.
Apr 19 '12 at 02:45 PM
maroonrs2
Dude are you serious? You get help and complain? Know what, last time with you moronrs2. You already showed a bad side of you earlier today in another post, now you confirm. Your -16 credit says it all on your programming skills, don't bother showing me your results.
Apr 19 '12 at 03:25 PM
fafase
(comments are locked)
|
|
Sure you call the function every Update so it's called every frame. Your whole coroutine "mess" effectively does this: It seems you want to slow down the instantiate rate. You can use a single coroutine for that which means it has to be started only once. Something like that: Nope sorry, it starts one instance. Then it will repeat the clone process too many times in one go. Then it will wait. so like 20 instances was recorded in 2 seconds. It was confusing cause it had like a short trail.
Apr 19 '12 at 02:42 PM
maroonrs2
That doesn't make much sense. Are you sure you have only one instance of this script on your "cannon" object and are you sure you called the coroutine in Start() and not in Update()?
Apr 19 '12 at 03:01 PM
Bunny83
(comments are locked)
|
|
You put an yield inside waitNGO function, but that's not sufficient: function Update continues to operate every frame. As a result, you have a bunch of calling to the wait NGO function: each of them will wait using the yield, but all of them will be already "queued" for the execution, and the "wait" is nullified. You can solve introducing a variable (lock) that controls when waitNGo has finished or not its execution. So what you just said is add a debouncer. Gotcha.
Apr 19 '12 at 02:33 PM
maroonrs2
Good work but im going to see what other people posted.
Apr 19 '12 at 02:39 PM
maroonrs2
(comments are locked)
|
var timing:int; And i also see that you forgot a } in the process First he didn't forget the "}"... it's still behind the Destroy call so you have one more now. Also you didn't align your code that much better. Second why do you post his solution as additional answer?
Apr 19 '12 at 03:46 PM
Bunny83
(comments are locked)
|
