Game Development Community

gravitation, high object velocity, and accurate collision detection

by Andrew Simms · in Torque Game Builder · 12/12/2009 (3:55 pm) · 1 replies

Hey all,

I'm currently working on jump mechanics for a basic platformer. My design resolution is set to 1280x720, and the player object I am using is approximately a 125x125 px square. In order to control the arc of my player's jump, I am using setImpulseForce() to kick the character off the ground, paired with a constant downward force applied to the player that eventually overcomes this impulse force and pulls the player back down.

My problem is this:

I've found that in order to accelerate/decelerate the player at a believable speed when jumping, the forces I have to apply are irregularly large, and result in the player object jittering on the ground. However, if I lower the forces, the jittering disappears, but then I am stuck with a player object that can barely jump 1/4 of its height as opposed to the former which could jump over 3 times its height.

Is there a way I can allow my player to move the proper screen distance, while maintaining my current resolution, without having to apply huge forces/velocities to my objects in order to get them to move at the speed I want, so I can get my initial jumping results without any jitter?

About the author

Recent Threads


#1
12/17/2009 (7:18 pm)
Well, I've been working on this and have taken a new approach to this problem.

Rather than implementing constant force on my player, I've instead swapped to a method where gravitational acceleration is enabled/disabled depending on whether the character is going to collide with a walkable surface. The gravitational force itself is no longer being applied via a constantForce, but rather, through incrementally increasing downward velocity per physics tick (EX: player.setLinearVelocityY(player.getLinearVelocityY + 60))

So now I'm working with onSceneUpdateTick(), having my script add velocity to the player, using castCollision to detect if the player is within range, then either zeroing out my Y-velocity or maintaining my speed based on the results.

With this new approach however have come some odd issues that I'm still working on patching up (stopping too early above surfaces, not properly detecting walkable surfaces beneath the player tick by tick, etc etc)

While I'm sure many have resorted to getting their hands on the platformer kit at this point, despite that, I figure learning how to set this up is part of the experience, so I'd be interested to hear how people have been tackling the issue of gravitation and high velocity.