How do I create a weapon change

Get help using Construct 2

Post » Sun Feb 15, 2015 8:55 am

Since my original question at the beginners section seemed to go nowhere, i figureg i might step it up a bit and ask basically the same thing here.
Im trying to create a game similar to crimsonland where you have hordes of enemy coming at you and you try your best to keep them at bay until the inevitable defeat. The player has only one weapon to use at any given time, but can change the weapon if anotherone is spawned to the playfield.

What i would want to create, is the player to have a max of two weapons at his/her disposal. a primary, and a secondary weapon. That he could change should an enemy drop one for example.

Where i've gotten so far, is that i have the player start off with nothing. he can pick up two weapons that shoot their own bullets and the weapons can be changed through mousescroll. Now on the mousescroll change, i have a bit of an issue that i cannot seem to figure out. The weapons on the ground react to the mousescroll before i've even picked the up. How would i set it so they only react to the mousescroll if equipped by the player? Another issue is the bullets. I've got a shotgun on the game that shoots a burst of pellets. Problem is, all of the pellets dissapear after only one hits an enemy or goes over the grid. I assume this would be related to the fact that the bullet has a container that has the rest of the pellets attached to it.

Code: Select all
The gamefiles can be found at https://www.dropbox.com/sh/j9xxg9strbnfw5z/AADeIzHrZkAt_mDV036b7Klaa?dl=0 to see what i mean. Or https://dl.dropboxusercontent.com/u/73502848/New%20project/index.html to test the game on a browser.

^-- i guess im not allowed to post url:s , but im assuming im not hurting anyone here by going around the blocking like this..
B
7
S
1
Posts: 93
Reputation: 632

Post » Sun Feb 15, 2015 9:15 am

Fastest solution would be to add pinned condition, like in picture.

Although you will need something more complex if you add more weapons.
You do not have the required permissions to view the files attached to this post.
B
12
S
6
G
2
Posts: 99
Reputation: 1,727

Post » Sun Feb 15, 2015 9:49 am

Two weapons demo
You do not have the required permissions to view the files attached to this post.
B
226
S
31
G
14
Posts: 1,899
Reputation: 38,302

Post » Sun Feb 15, 2015 11:13 am

That not all of your bullets get destroyed, make sure you pick every single one.
For example:

-For each Bullet
-- On collision with Monster
~ Bullet Destroy


I can't imagine for what reason you've created a container for your shotgun pellets.
Try to remove it, because according to my knowledge it would destroy all others as well as long as they're within the same container.


and for the weapon pick up.
Simply add a "equipped" boolean instance variable to the weapons.
Then add a check when switching weapons.

If "equipped" True


With that you can prevent that you set them invisible while they're still on the floor ;)
B
35
S
8
G
3
Posts: 135
Reputation: 2,840

Post » Sun Feb 15, 2015 8:23 pm

Thanks razor monkey for the advice, that worked like a charm, now that i see that, its so obvious i feel silly.

Everade, im not entirely sure why i used that container in the first place. Guess i sort of though that a shotgun shell is a container of pellets..sooo :) anyway, changed it so that each pellet has its own destroy on collision state. Works fine now, thanks! I didnt try this boolean thing just yet as Razor monkeys advice worked great, however. Now that i got the two weapons to work like i want, im curious if this way i could use more than two weapons at a time?

Lordshiva, thanks for that. I remember you posting a reply to the other thread as well. However, this type of weaponchange does not really work with my project. Much appreciated nonetheless.
B
7
S
1
Posts: 93
Reputation: 632


Return to How do I....?

Who is online

Users browsing this forum: Cryttexx, KNTMartin, newt, ridhoemgl and 7 guests