Weapon Selection help please?
allc1865
Member, PRO Posts: 777
Hey everyone. I'm trying to create a weapon selections where I can select the kind of weapons I want. I've tried watching GSHelper's multi weapon selections, but I'm using a joystick and so I think that's where it went wrong because it doesn't work, and by that meaning, when I shoot, it only shoots in one direction and in a small little pile next to my player. Not what I wanted.
Any help would be great! Thanks you!
Any help would be great! Thanks you!
Best Answers
-
ZeroRaven Posts: 33allc, I've used multiple weapons like this before. How did you want to switch weapons forst off?
When I did it I used the 1,2,3,4 keys and had each tied to a game attribute.
so
When:
Key (1) is pressed
Do:
Change attribute (game.weapon1) to true
Change attribute (game.weapon2) to false
etc.
So when you press your fire button it should have a code to check which weapon is selected.
When:
Key (trigger?) is pressed
Do:
If attribute (game.weapon1) is true,
spawn selected actor.
This way you can have each weapon have different properties.
You'd wanna make sure though that you have code is the initial weapons selection to DESELECT the other weapons.
Hope this helped. -
tatiang Posts: 11,949Constrain a gun actor to the tank actor so that its x/y position is constrained to the x/y of the tank. Do not put the constrain behavior inside of a rule.
Change the image and rules according to a game attribute such as game.weaponChoice.New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
-
tatiang Posts: 11,949@allc1865 You're welcome!
Pro members can upload a .zip file or other attachment to the forums. Anyone can post a link to a hosted file.New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Answers
What behavior are you using on the bullet actor(s) to move them? If you spawn a bullet actor, it won't automatically go anywhere. You have to use something like a Move behavior to move it across the screen. Set the direction to 0 or 90 relative to actor (it depends on the size of your actor, so try both).
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
I've got it working this way -- I'm not sure if this is the best way, but I'm using true or false statements to get a different bullet to shoot out.
So basically, the button that you press to get a different bullet to shoot out says, when touch is pressed > change attribute game.weaponAmmo to true.
In the bullet actor I have it saying, when attribute game.weaponAmmo is true > change image.
It seems to work this way...
I was referring to #2 and wondering how you're having the bullet move...? Maybe you can post a screenshot of your Spawn rule and your bullet rules/behaviors so we don't go 'round in circles.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
these are the rules for my bullets in my player actor:
these are my rules for my bullet actor:
Note: The rules that says "when weaponAmmo is true change image", that is what I recently added to make my bullet change when a button is pressed. I wasn't sure if you wanted to see that or not.
Thanks for your help.
As far as the bullet movement goes, did you experiment with 90 degrees as well as 0 degrees? If you want to send me a link to download your project file, I may have more luck if I see how you have it all set up.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
I guess I'll just start off with the second one. If I wanted to have a particular gun or so attached to my actor when button is pressed, how would I do that? When touch is pressed constrain attribute gun to player?
Thanks for all your help!
Thanks for your reply, @tatiang
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
In the demo, you use the arrow keys to move and rotate the tank body. The A and S keys rotate the turret and the space bar fires a bullet.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Let me ask. What do you mean by "Change the image and rules according to a game attribute such as game.weaponChoice"?
In the turret/gun actor, have a rule that says When attribute game.weaponChoice=2 ... Change whatever attributes you want to be affected, such as rotate speed, spawn rate, etc. Do the same thing in the bullet actor so that it's speed or damage or whatever are also affected by the value of game.weaponChoice.
Then if you want a flamethrower, it could be game.weaponChoice=3 with rules for that value.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
If you don't mind me asking, how do you get your project file that you've zipped to show up on the webpage instead of posting a link?
@tatiang