|
I know this has been asked but I can't find an answer that suits what I'm trying to do. I have a setup where my FPS player starts off in a house with no weapon selected. He finds on on the wall and picks it up. I'm using this as my pickup for the weapon:
The gun dissapears from the wall and it prints out that you have "You Picked Up The Double Barel Shotgun" So far so good. What I can't figure out is how to get it to activate and load up the shotgun from my PlayerWeapons script
3 months of trying to learn this code stuff and a lot of it still makes my brain hurt lol. Anyone know how I can make this work?
(comments are locked)
|
|
Try this.
All you have to do now is to make the mesh activate. More detail needed, let me know.
(comments are locked)
|
|
First of all. This code:
Is a good candidate for a function:
So when you want weapon "1" you can just call selectWeaponByIndex(1). Now.. when you pick-up the shotgun you should broadcast a message that you did. Have your PlayerWeapons script respond to this by selecting the shotgun. Thanks flaviusxvii, not sure I really get what you are doing here, can you perhaps explain in more detail for those of us code challenged ;)
May 12 '11 at 09:04 PM
Michael 12
I don't know what you're asking me to clarify? Functions? Broadcasting? You already have examples of both in your code. Use those as templates.
May 12 '11 at 09:14 PM
flaviusxvii
OK well, like I say, this code stuff a lot I don't get so when I changed my code to what you have here I get an error message that I don't know what to do about: Assets/WeaponScripts/PlayerWeapons.js(15,10): BCE0044: expecting (, found 'selectWeaponByIndex'.
May 12 '11 at 09:20 PM
Michael 12
http://pastebin.com/idbGRjGK <-- Like this for the function change..
May 12 '11 at 09:42 PM
flaviusxvii
Ok I changed my script to that but it does not equip my gun to my player, so what am I missing? It took me a while just to see what was different about my script and the one you have.
May 12 '11 at 10:40 PM
Michael 12
(comments are locked)
|
