How do I fix and efficiently create a pick up & throw system

1 favourites
From the Asset Store
Awardkit
$3.50 USD
30% off
Create custom awards and achievement or use the many templates and create your own.
  • Hello all! I'm trying to create a simple pick up and throw system. I made one but I'm having some issues. I also have some general questions about making a large game and C2 if any can help.

    My problem: My player is throwing the box at downward angle. I want it to look like some simple NES looking throw. Something out of Duck Tales or Mario 2. I can't get the time for my events right. Am I doing this the right way? Also, how do create a pick up movement or animation, set moves the box from the floor to above the players head?

    General questions: I plan to have many objects you can pick up. How would I do this? Would I make a family called Pickables (or whatever) and add all the sprites I can pick up in it? What if I wanted to make each Pickables to slow down the player or be thrown at a shorter or further distance? I know I would use a instance variables on the objects but how would I go about coding this? I know how I would manipulate travel distance and player speed for each pickable. How can I code this for family and the most effiecent way? I'm having problems understanding when and when I shouldn't use functions.

    Thanks for looking at my post!

  • I would start with:

    When Box Picked up > Move Box negatively along the Y axis. Seeing as your players height will never change, this shouldn't be too difficult.

    I remember in Mario 2 they used to snap the object to be infront of the player and then move it up and above the head.

    Set your animations, like "Arms Up", if you have something like that.

    Enable Pinned to Player. Set your "Carrying an Item" variable.

    Then have an event where, if the player presses A, enable bullet movement and unpin on the carried object.

    Have a sub-event, that will set the direction of the bullet based on the direction the player is facing. Facing Right set the angle of motion to 45 degrees, and facing Left to 135 degrees.

    I would also disable collisions on the object once it has been thrown so that it falls off the screen. Then destroy it. You can handle enemy collisions (if you are using the object as a weapon) by checking for overlapping.

    Unless you want to keep the objects you are picking up, for like building blocks or something.

    Does that help?

  • For picking up and throwing part, I have created two examples.

    Throwing via Bullet

    https://www.dropbox.com/s/l13oezvjoqyjw ... .capx?dl=0

    Throwing via Physics

    https://www.dropbox.com/s/tlaj11i5ewazg ... .capx?dl=0

    1. How do create a pick up movement or animation, set moves the box from the floor to above the players head?

    That's easy. When a box overlaps or in collision with Player, set Box's potision to Player's Imagepoint 1 (located above Player's head).

    I would create an animation with arms up, as if the Player is holding a box nesting on his/her head.

    For Super Mario Bros 2's throwing style, check out this thread.

    how-do-i-make-super-mario-bros-2-styled-throwing-system_t150822

    2. I plan to have many objects you can pick up. How would I do this? Would I make a family called Pickables (or whatever) and add all the sprites I can pick up in it? What if I wanted to make each Pickables to slow down the player or be thrown at a shorter or further distance? I know I would use a instance variables on the objects but how would I go about coding this? I know how I would manipulate travel distance and player speed for each pickable. How can I code this for family and the most effiecent way?

    Please check out this tutorial by cacotigon. <img src="{SMILIES_PATH}/icon_mrgreen.gif" alt=":mrgreen:" title="Mr. Green">

    https://www.scirra.com/tutorials/556/un ... o-families

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Tekniko Gmoney Thanks a lot guys! This helped a ton! So I modified my throw events to work more like Gmoney's capx. Will modify this further with added functions, added variables and other goodies. I want items you can throw to be used as weapons, for puzzles and other sequences. This pink box specifically helps you reach a higher platform but this other throwable items can also hurt enemies as well.

    So the throw works nicer but I now have a bug where eventually my character will start throwing the object in the opposite direction or just get stuck throwing it in one direction. Sometimes this bug will happen immediately, sometimes it'll take a few throws. Here are my events.

  • Tekniko Gmoney Thanks a lot guys! This helped a ton! So I modified my throw events to work more like Gmoney's capx. Will modify this further with added functions, added variables and other goodies. I want items you can throw to be used as weapons, for puzzles and other sequences. This pink box specifically helps you reach a higher platform but this other throwable items can also hurt enemies as well.

    So the throw works nicer but I now have a bug where eventually my character will start throwing the object in the opposite direction or just get stuck throwing it in one direction. Sometimes this bug will happen immediately, sometimes it'll take a few throws. Here are my events.

    You're welcome, heyguy..!! <img src="{SMILIES_PATH}/icon_mrgreen.gif" alt=":mrgreen:" title="Mr. Green">

    This method will correct the throw bugs.

    https://www.dropbox.com/s/2djw1gykv1rft ... .capx?dl=0

  • Thanks again for your help! I fixed it by doing this.

    Simple fix. I do have another issue maybe you or someone else can help me with related to this. I want the box (and any other throwable objects) to land flatly on the ground (tilemap). If it hits a wall, I want it to just fall straight down on the ground. Well...if I hit the tilemap anywhere other than the ground, the bullet disables and it stays stuck in the air.

    If I do hit the ground, the box doesn't land directly "on" the ground. It's a few pixels inside the tilemap. Is there anyway to fix this, it looks a little sloppy. This issue is noticeable on the gif above.

    I'm making a retro style pixel art game. I suspect that maybe making the box into a physics object might resolve this? Will that rotate the angle of the box if thrown? Can I restrict that? I want to maintain NES looking gameplay and system restrictions. And I'm making a mobile game so I don't want to tax the phone with any unnecessary resources.

  • You're welcome, heyguy. <img src="{SMILIES_PATH}/icon_mrgreen.gif" alt=":mrgreen:" title="Mr. Green">

    I have removed the 'bullet disabled' event from the event sheet, and added Box.Bullet.Speed / 5 on collision with walls.

    https://www.dropbox.com/s/ghumj02vn62rm ... .capx?dl=0

    For the thrown object's overlapping issue with tilemap, I would look into the object's set collision polygon to check first; after going into C2's image editor.

    If everything is found to be correct there, then we'd need to investigate further. <img src="{SMILIES_PATH}/icon_mrgreen.gif" alt=":mrgreen:" title="Mr. Green">

  • One behaviour 4 everything. Including flying things.

    https://www.dropbox.com/s/toa0mse2r2n8v ... .capx?dl=0

  • One behaviour 4 everything. Including flying things.

    https://www.dropbox.com/s/toa0mse2r2n8v ... .capx?dl=0

    Wow! <img src="{SMILIES_PATH}/icon_e_surprised.gif" alt=":o" title="Surprised">

    I can never catch up with your advanced skills, 99Instances2Go. <img src="{SMILIES_PATH}/icon_mrgreen.gif" alt=":mrgreen:" title="Mr. Green">

    That's an amazing example. (e.g. Pick distance(BadOne.X,BadOne.Y,Player.X,Player.Y)) -> <img src="{SMILIES_PATH}/icon_e_surprised.gif" alt=":o" title="Surprised"> )

  • He said that he wanted it to fall when colliding with the decor.

    So, you got to handle 'the fall' and 'the push-out-of-solids'.

    The fall (gravity wise) is very very easy with platform behaviour. (or physics)

    And for the other 'thing', it is absolutly neccensary to not push it into solids. Platform behaviour is made for that. (so is physics)

    But because there is allready a platform in play, i choosed platform above physics. This way the events stay in one and the same mind-world.

    The push-out-of-solids is key in this story.

  • Thank you very much for the information, 99Instances2Go.

  • corporatedrone Good question, I'm not sure the answer! I'm not sure but I can try and I'll make an attempt.

    TFor a 8 Direction Game, that's probably different in some ways since you have you account for all 8 directions and z axiz. Am I right guys? If it's a beat em up, presumably you can't have a solid on your ground? I have no idea how to work with z axis but this is the system I would create, if things work similarly. I'd give the throwable an booleen called inAir (though an instance v may be better) and set a timer to have it switch off. Or switch it off When the throwable destroys on the ground or the enemy.

    If you had bat enemies that fly, this though, would mess up when throwing in the up or down directions I think though.

    99Instances2Go Thanks so much for the awesome capx example! Will implement the changes soon. I love that little extra creature too!! I'm currently making a bunch of different A.i. pattems so it's great to see examples of different code! It's really helpful checking out example likes of unique behaviors.

  • How would this work for a game with 8 directional movement (like a beat em up game)?

    Show me an example of using 8 directional in a beat em up? I dont see 'it'.

    I can see 8 directional in a top down, but trowing is then just a straight line ?

  • > How would this work for a game with 8 directional movement (like a beat em up game)?

    >

    Show me an example of using 8 directional in a beat em up? I dont see 'it'.

    I can see 8 directional in a top down, but trowing is then just a straight line ?

    I've been using this

    https://www.scirra.com/store/royalty-fr ... lling-1134

  • Dont know what exactly to do with the ground.

    https://drive.google.com/open?id=0B1SSu ... Xd5NVBMeTg

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)