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 / Need some help with collision and physics

Author
Message
Digital Awakening
AGK Developer
21
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 18th Jul 2012 14:01
Working on a tile based platformer and the built in collision and physics is driving me nuts. Using the physics commands to move the player is quite bad for what I want to do, very imprecise. And the way it interacts with the world is just annoying, getting stuck everywhere.

Now I wan to use the built in collision and handle the physics myself. But to get access to the contact list I need to use physics objects. But that's not all. The player has to be dynamic or I won't get any contacts, tried both kinematic and static. But if the player is dynamic then the built in physics will handle collisions, moving it around.

So I want contact data without AppGameKit moving my sprites around. Can that be done?

Digital Awakening
AGK Developer
21
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 18th Jul 2012 16:00
Seems like I can use a dummy sprite for collision detection as they are not updated by the physics. But seems to me like an unnecessary step.

Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 18th Jul 2012 17:48
Perhaps it would be better to only use the dummy sprite when the character gets stuck. For instance, if the movement speed is >0, and the character is in the same position as the last frame, then use the dummy sprite to help find the nearest, safe location to warp to.

I want to try and make a test platformer and tiled map example - actually thinking about remaking level 1 from Super Mario Bros, so I'll let you know if I uncover anything useful. I'd prefer to excercise some demons before attempting any decent sized projects in AppGameKit, seems collision detection is as big a demon as it ever was.

Health, Ammo, and bacon and eggs!
MarcoBruti
12
Years of Service
User Offline
Joined: 20th Nov 2011
Location: Caput Mundi
Posted: 18th Jul 2012 18:03
I have no problems with collision detection, have a look at [WIP]MrOttoBeat platform game, I use both physics and non-physics sprites, simply iterating and using getPhysicsCollision() (for physics), and getSpriteCollision (for non-physics). I also use getSpriteFirstContact() for physics sprite in order to avoid to iterate all the times if there are no physics coincidence.
Digital Awakening
AGK Developer
21
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 18th Jul 2012 18:07
Right now my solution is to turn off physics for the player sprite and use only a dummy sprite. Then I can manually move the dummy sprite each frame, check for contacts and then position the player sprite.

But I'm tired of working with the gameplay and working on my worldmap instead. Finally some progress!

Login to post a reply

Server time is: 2024-05-05 17:18:50
Your offset time is: 2024-05-05 17:18:50