How to pick up weapons(help,capx included)

0 favourites
From the Asset Store
Pick Up Items Sound effects for your game, Take them for a ride right now and you will worry no more.
  • I've been trying to get this code working for a few weeks with no success. ive read some posts but still don't understand certain codes that some have provided. i have included the capx file on this thread.

    In the file, you'll only be able to pick up the Bat, since i was testing it. Another thing is that when youre overlapping another weapon, youll still be able to pick up the Bat.

    I've included 11 weapons, i want to be able to pick up each weapon individually without picking up multiple instances at the same time.

    Basically, the simple pick up and drop weapon.

    dl.dropbox.com/u/101797089/WeaponInstances.capx

  • I can't look at your capx right now, but you might want to try a variable like 'holdingWeapon' or something which is true if he has a weapon, and is checked to be false before he picks up a weapon.

  • I can't look at your capx right now, but you might want to try a variable like 'holdingWeapon' or something which is true if he has a weapon, and is checked to be false before he picks up a weapon.

    Thanks for the reply. It's little more complicated than that my friend. Whenever you have free time i would love if you checked the capx.

  • I'm using an older version of C2 so can't check it myself.

    I'd probably use holdingWeapon to store the UID of the weapon sprite. Then only one weapon can be held at a time. You said it's a little more complicated than what sqiddster suggested, so not sure if my suggestion would work, but you never know!

  • I'm sorry, but it's very hard to find out what your code is doing, considering its size and lack of comments.

    If you could make a stripped-down capx with only the problem you are referring to, that will make it much easier for us to help. I'm sure you understand.

  • Iplaygames is using a pickup variable already and it does determine if its picked up or not. Perhaps someone else can look at the capx and see what can be fixed.

  • I believe the problem is the melee intances group and the pick up group. Iplaygames is basing the id of a weapon based on the sprite that is randomly generated at the start of layout.

    If a bat is selected, the bat will have a weaponttype value of 1, if its a crowbar it will be 2 and so on.

    In the pickup up group, which is just one line of code its where I think the problem lies. Its basically if your overlapping the melee object and press down it will pick It up. But its not very specific so it can pick up any weapon. Should values be used to identify a certain sprite or maybe something else?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • OK... now why do your weapons all have the platform behavior? That seems really odd to me and the code is very confusing.

  • Thinking more about it now after reading the discussion after my reply, I can say yes, it'd be better to store each weapon with its own value.

    currentWeapon = "gun"

    and "gun" would be the name of the sprite so it would be easier to match and pick. At least that's how I did it in a shooter I started in CC. The problem with using values to represent the weapontype is it's harder to read through events and debug.

    Unless I'm still misunderstanding because I can't check out the capx.

  • The platform behavior was a way to get gravity working for the melee objects, it could be done many ways actually. But the goal is to pick up only one instance of a weapon without picking up the rest.

  • Have you tried 'pick nth instance', to pick the 1th instance?

  • Theres an event that reads:

    Is animation d1 playing- set wpntype value to 1

    (d1 being bat)

    So yes you are pretty close. We are having a problem trying to overlap an instance and only pick up that instance. But there is no such event. We tried:

    player overlapping melee + pick unique ID 1. that didn't work

    then we tried:

    player overlapping melee + wpntype is 1. that would work, but if you have more than one of that same wpntype it would pick up both no matter how far apart.

  • ssqidter Yes we have tried that also with the same result. We are willing to change the pick up/instances code if there is an easier method.

  • I'm looking at your capx, but nothing seems to work for me. I can't pick up any weapons, and I have a bat moving and jumping towards me...

  • I haven't looked at the .capx, but what about something like:

    If player overlapping weapon

    Player variable 'weapon' = "none"

    Pick closest weapon to player.x, player.y

    • set player variable 'weapon' to weapon.type
    • destroy weapon

    On button to drop weapon pressed

    If player.weapon="bat"

    • create object bat at player.x, player.y
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)