Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Physics movement issue

Author
Message
gsdblack
12
Years of Service
User Offline
Joined: 6th Dec 2011
Location:
Posted: 17th Apr 2013 17:27
I'm working on platformer when the player is constantly moving right and can jump. I tried to do it with out physics but when I "jump' it doesn't really jump. It just places the player -y and isn't really jumping.



I tried movement with velocity and impulse but the player wont jump.



Then I tried force and impulse but it seems the player only move in the air. I guessing it is because of friction but I don't know how to solve that.



What am I doing wrong?
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 17th Apr 2013 17:35 Edited at: 17th Apr 2013 17:39
use physics movement only with force or impulse.
the best start of force is getspritexbyoffset() & getspriteybyoffset() , this is the standard middle of your sprite.

you forget to set the y pos. parameter.

agk::SetSpritePhysicsForce(cynthiaSprite, agk::getspritexbyoffset(cynthiaSprite), agk::getspriteybyoffset(cynthiaSprite), 2000, 0 );
lilpissywilly
AGK Developer
14
Years of Service
User Offline
Joined: 10th Sep 2010
Location: Office Chair
Posted: 17th Apr 2013 18:11 Edited at: 17th Apr 2013 18:39
Like Markus said you should use GetSpriteX&YbyOffset.

But also in your jump code, try this:



If this does nothing, the force is too low for your object, so try -500 or something instead on the Y force.

Edit:
If you want your jump to behave the same no matter what other forces your object is subjected to, you can use setSpritePhysicsVelocity.



My hovercraft is full of eels
bitJericho
22
Years of Service
User Offline
Joined: 9th Oct 2002
Location: United States
Posted: 18th Apr 2013 04:47
What I did to get very reasonable values was choose a scale for size and mass. I chose 1 unit is a meter and kg for mass. Then I made a reasonable sized and weighted sprite and let it drop. I then tweaked my friction value until terminal velocity was right. This will also confirm your gravity is right. Anyway, once your object is moving in the world correctly you can start tweaking impulses knowing you're using reasonable numbers. When tweaking impulses, you may also want to keep track of the sprite speed so you know how fast they are moving and are moving appropriately fast for your game.

Visit my blog http://www.canales.me.
gsdblack
12
Years of Service
User Offline
Joined: 6th Dec 2011
Location:
Posted: 21st Apr 2013 21:10
I've tried what you guys posted but it still doesn't look/feel right. How can I make the player jump without physics.
Marl
13
Years of Service
User Offline
Joined: 19th Nov 2011
Location: Bradford, UK
Posted: 24th Apr 2013 20:42
You can simulate physics. I've had a lot of success with a "stripped down" physics model for similar ideas that don't need the full physics effects.

Each object is assigned properties for position,speed and acceleration for the axes you want to work with. Then each loop - or at an interval which suits your game - you add the acceleration to the speed, then add the speed to the position.

Each property has a maximum and minimum value to stop it getting silly, but the rest is pretty much self working.

I used it for a space type movement system ( parameters for x, y and angle ) and it provided a very realistic feeling of inertia.

I'll see if I can dig out the code.
gsdblack
12
Years of Service
User Offline
Joined: 6th Dec 2011
Location:
Posted: 8th May 2013 06:05
Sounds complicated..... Could you dig it up for me?
Marl
13
Years of Service
User Offline
Joined: 19th Nov 2011
Location: Bradford, UK
Posted: 8th May 2013 09:33 Edited at: 8th May 2013 09:34
Here's the setup for the objects


And here's the loop code;


and here are some functions used by the loop

It's stripped out of a project, there should be enough to get something going - I hope you can make sense of it.

Login to post a reply

Server time is: 2024-11-24 14:04:55
Your offset time is: 2024-11-24 14:04:55