main character of game needs to continually bounce up and down while being able to receive input frm user swipes

Hi guys, i have a basic main character of the game, who ive applied physics to. I need to start by continually making him bounce up and down whenever hes on a solid surface like the ground.

any pseudo code ideas? also little confused if i use physics to do this, how do i enable user touch events as well tht will enable the character to be moved?

[import]uid: 130366 topic_id: 33020 reply_id: 333020[/import]

Apply an upwards linear impulse whenever your character collides with the ground, might be an idea to set a flag that indicates the player has bounced which resets while he is in the air, to prevent the impulse from being applied more than once per bounce.
[import]uid: 93133 topic_id: 33020 reply_id: 131069[/import]

Hi @jacksparrow.greg,

If you’re using “swipes” to move the character, it will be the screen which senses the swipes, and that data will be used to move the character. Don’t apply the touch listener to the character itself, since it would likely be difficult for the user to swipe “over the character” to move it.

Nick’s idea of applying a linear impulse and using a flag to prevent multiple swipes is a good and valid suggestion. I would additionally suggest that you apply the upward force after a tiny delay following the bounce. If you apply it immediately on collision with the ground, you’ll be counter-acting the downward force (falling) with the new upward impulse, and it will probably “cancel out” and yield little result. So, perform the upward impulse after a short delay… 50-100 milliseconds perhaps. This will allow the character to naturally bounce off the ground and start its upward movement, and then your impulse will “boost” it upward nicely.

Best of luck!
Brent Sorrentino
[import]uid: 9747 topic_id: 33020 reply_id: 131087[/import]

Apply an upwards linear impulse whenever your character collides with the ground, might be an idea to set a flag that indicates the player has bounced which resets while he is in the air, to prevent the impulse from being applied more than once per bounce.
[import]uid: 93133 topic_id: 33020 reply_id: 131069[/import]

Hi @jacksparrow.greg,

If you’re using “swipes” to move the character, it will be the screen which senses the swipes, and that data will be used to move the character. Don’t apply the touch listener to the character itself, since it would likely be difficult for the user to swipe “over the character” to move it.

Nick’s idea of applying a linear impulse and using a flag to prevent multiple swipes is a good and valid suggestion. I would additionally suggest that you apply the upward force after a tiny delay following the bounce. If you apply it immediately on collision with the ground, you’ll be counter-acting the downward force (falling) with the new upward impulse, and it will probably “cancel out” and yield little result. So, perform the upward impulse after a short delay… 50-100 milliseconds perhaps. This will allow the character to naturally bounce off the ground and start its upward movement, and then your impulse will “boost” it upward nicely.

Best of luck!
Brent Sorrentino
[import]uid: 9747 topic_id: 33020 reply_id: 131087[/import]