|
Hi guys i am making a game similar to worminator. However my shooting script doesnt work in that my character doesnt even fire the bullet although movement works, can you have a look at it and see whats wrong.
Thanks
(comments are locked)
|
|
Mabye like so:
Good old TornadoTwins, he is awesome ;) ok it works apart from it says the thing you want ot instatiate is nul?
Feb 01 '11 at 06:23 PM
lolage
also do i need to put where it actually forms?
Feb 01 '11 at 06:25 PM
lolage
I have found the error. At the end of the script above the "if statement" There you declared a variable(var) but you had also declared it at the top. I assume that Unity did not like that. I will update the script :)
Feb 01 '11 at 07:27 PM
OrangeLightning
That'll cause null ref exceptions every time after the first instantiation
Feb 02 '11 at 01:29 AM
Mike 3
(comments are locked)
|
|
This should fix it:
First change is that it needs to use if, not function, to check if the key is down Second is that you need to assign the Instantiate to the Bullet prefab so you can use it after Third is that you need to Instantiate bullitPrefab, not Bullet (which is completely empty still) It doesnt seem to work :( firstly i see that it says expectin } found " on 17,1. Secondly do i need to change the word bullit prefab to my bullet and thirdly do i attach it to the actual character?
Feb 01 '11 at 05:47 PM
lolage
ok so i filled the bullit prefab and thats ok, all i need to know now is why it wont actually run because of the "expecting } found " on 17,1."
Feb 01 '11 at 05:59 PM
lolage
You may want to edit your question with the entire code. Replacing from var Bullet : Transform up until the first } with my code should have fixed it
Feb 02 '11 at 01:30 AM
Mike 3
(comments are locked)
|
|
It doesnt seem to work :( firstly i see that it says expectin } found " on 17,1. Secondly do i need to change the word bullit prefab to my bullet and thirdly do i attach it to the actual character?
(comments are locked)
|

I added the code into a code block to make it readable - For next time, please select the code after you've pasted it, and click the button with 0's and 1's on it (like 110101, i forget exactly)