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 / AGK - Physics Help!

Author
Message
Benner
11
Years of Service
User Offline
Joined: 5th Mar 2013
Location:
Posted: 5th Mar 2013 02:45
I'm trying to complete a project for school(2d side-scroller), and I'm stuck on a problem.

The problem is with trying to move the character and keep gravity. Right now i can have either gravity pulling him down or i can move his position.

agk::SetSpritePhysicsVelocity(spriteIndex, speedX, speedY);

that's how I'm changing his position(tried using agk::SetSpriteX same thing)

I'm using visual studio 2008.

this is my first time here so it may be in the wrong spot but any help would be appreciated.
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 5th Mar 2013 09:53 Edited at: 5th Mar 2013 09:53
The problem is that you are setting the vertical velocity every loop. To use the physics system gravity you just need to let it make it's own mind up what velocity to apply like so:
agk::SetSpritePhysicsVelocity(spriteIndex, speedX, GetSpritePhysicsVelocityY(spriteIndex));

Welcome to the forums by the way


this.mess = abs(sin(times#))
Benner
11
Years of Service
User Offline
Joined: 5th Mar 2013
Location:
Posted: 5th Mar 2013 16:52
Thank you!, I was sitting there or 3+ hours at this last night, I guess through staring at code for so long I just passed that function
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 5th Mar 2013 16:53
It's not that obvious anyway but generally if you set the position or velocity manually you negate any other forces.


this.mess = abs(sin(times#))
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 5th Mar 2013 18:43
interesting too
SetSpritePhysicsForce
SetSpritePhysicsImpulse

Login to post a reply

Server time is: 2024-05-06 21:18:37
Your offset time is: 2024-05-06 21:18:37