Ambiera ForumDiscussions, Help and Support. |
|
|
|||||
|
What is the best way for making a weapon change system?if give me a source i will be so happy |
||||
|
Hey, Here's some code from my game, I hope it helps you learn how to make this, https://pastebin.com/CQAMsqJ9 You might not understand it completely, because I write code weird and fail to comment where necessary but if you have any questions just send me a message on facebook https://www.facebook.com/deltaxgames |
||||
|
I dont have facebook This ia behaivier?or i shoul change some parts? |
||||
|
No it's not a behavior. Here's how I added it to my project. Click on the root scene node and add a "on first drawing do something" behavior . Then click that and add an "Execute Javascript" action, paste the code there. Rename the weapons in my weapon array to be the same with the weapons you used in your game. Make sure all the weapons are not visible, uncheck this attribute in all the guns. Now you need to add two "when a key is pressed do something" behavior,one for switching forward and and another for switching back between weapons. Just execute this JS when someone clicks the next weapon key nextWeapon(); and previousWeapon(); for when the player clicks the previous weapon key. And please by all means change it, it's very sloppy code and it includes a lot of things that are very specific to my game and may not be needed in your project. I didn't have time to trim out those parts. |
||||
|
|
||||
|
Then click that and add an "Execute Javascript" action, paste the code there. Rename the weapons in my weapon array to be |
|