Jump to content
  • Advertisement
Sign in to follow this  
Dtag

"Ice Cube" Physics-Game

This topic is 4444 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi As mentioned in the topic, Ive got collision working up to the part where I can slide like an ice cube above my world. Unfortunately Iam having some trouble with making it actual _game_ physics. To represent the player, Iam using an ellipsoid. So this ellipsoid slides above the terrain - something particulary unrealistic as a player actually walks - but I guess its not solvable in a better way. The thing is that I cant adjust friction and static friction so that it "feels good". ( My implementation of friction and static friction is as follows: Trace Sphere against World - get the material properties of the first hit - apply friction as: outvelocity=(1-friction)*inVelocity - apply static friction as: if (|inVelocity|<staticFriction) inVelocity=(0,0,0) - calculate the slide vector - collide with the world again ... ) A problem Iam seeing for example is this: the player walks up a sloped hill. Then he wants to stop, but since he still has velocity, static friction wont make him stop, the gravity pulls him slowly down the hill. When I set static friction too high, and Iam colliding with a tree for example, this happens: Iam walking forward ( the tree has friction and static friction set to 0 so that you can slide smoothly along ), you first collide with the tree, the resulting slide vector has a very low magnitude because we are pretty much walking right against it. Now in the second recursion step, we collide against the terrain underneath, since the Magitude of the velocity is very low because of the collision with the tree, static friction will make us stop. If we collided first against the terrain and I've tried adjusting this alot, but I never found a good setup. Is it at all possible to adjust these "physically correct" material properties to generate an unrealistic behaviour? Is it common to have hardcoded pieces of code that prevent the player from sliding when the source of force is gravity? Are my implementations of friction and static friction correct? Especially the case with the tree makes me wonder, as it yields different results if you first collide with the tree, and then with the terrain, or first with the terrain and then with the tree. Thanks alot

Share this post


Link to post
Share on other sites
Advertisement
That reply was too fast.
I think you need to sit down a while and Really think about the full rammifications of what I've said.

People don't slide, they have feet.
Think about how walking works for a while, realize that your entire approach doesn't make sense for walking locomotion.
Amhdalh's Laws says to fix the Big problems first...

Share this post


Link to post
Share on other sites
I AM aware of that it physically doesnt make sense - thats one of the first things I said in my original post. But i doubt you can show me one game that implements player walking as actual walking....

Share this post


Link to post
Share on other sites
The point he's trying to make is that your simulation is just not applicable to walking. you're simulating rigid body physics. the human body is not a rigid body. you have 2 legs that articulate with the ground and for all intents and purposes you don't slide ever under normal conditions. so... as long as you aren't actually simulating legs, you aren't going to be accurately simulating walking.

[EDIT:

Also, consider your tree example. Think about it in real life. If you walk up to a tree and make no conscious effort to reduce the force you are appling against the tree (i.e. change your direction of movement) you do not slide. you come to an abrupt stop, just like you are getting in your simulation. Sliding against vertical surfaces isn't "realistic" it's just more fun gameplay. So if you want realism, then you generally won't get surface sliding; if you want good, expected gameplay you will typically get that sliding.

]

-me

[Edited by - Palidine on September 19, 2006 12:00:09 PM]

Share this post


Link to post
Share on other sites
Quoting myself... "To represent the player, Iam using an ellipsoid. So this ellipsoid slides above the terrain - something particulary unrealistic as a player actually walks"

As I mentioned 3 times now, Iam aware of the fact that its wrong. Still theres probably hardly any game that doesnt do it this way. Iam just looking for a way to make game physics from that. I dont really care about realism. But I'd like to avoid hardcoded solutions for terrain. No more replies saying this is not realistic plz *g

Share this post


Link to post
Share on other sites
I recently implemented a system for 2D platforming, walking on arbitrary slopes (and moving/collapsing objects).

I used a circle for collision as well. I had the same ice-cube effect and was able to get rid of it, though the solution was a bit of a hack. I think that was the point of the previous posters (though if it was, you guys need to clarify yourselves or you just sound like you're telling him it can't be done. Some people aren't looking for a perfect physics simulation, he seems to be looking for something that will make his game fun.)

- If I collide with the ground, I project the characters position to rest on the ground and set its Y velocity to 0 for that frame. That keeps gravity from pulling him down the slope. When you walk forward, the projection allows him to climb the slope (and slows him down slightly, which is more realistic, though this can be changed if needed).

There are a few issues with this approach:

- It is only reliable with a fixed time step, and not for very fast moving objects.

- Walking down a slope isn't perfectly smooth (you walk forward, then fall, then forward, then fall) but with a quick enough time step (or some trickery) this can be remedied.

Overall, my character feels pretty smooth, so the technique seems to work ok.

Share this post


Link to post
Share on other sites
ah, sorry totally misunderstood the intention of the post. I'm not sure that your approach to player movement is going to work out though because of the above mentioned unrealism. The problem is that in the real world you are in control of your friction against various surfaces. Unless you are going to provide a mechanism by which the player can do this, I'm thinking that it's going to be difficult to find something that works nicely. The 2 solutions I know to be used are:

1) zero friction with everything: problems are that, like in other games that solve it this way, when you're on a slope you start sliding down (unreal, some versions of quake)

2) zero friction, but when the player is in contact with the ground do not apply gravity. With this you get no sliding but you have to construct other mechanisms by which you prevent players from running up steep slopes (generally invisible collision planes)

I'm not aware of anyone that simulates player movement using physics: again I think this is because of all the problems you are encountering and honestly physical simulation of player induced friction doesn't really add anything cool that I can think of to your game. If you get it right you likely will end up with something that behaves exactly like #2 above.

At the moment I'm not seeing any way to fix your problems without creating other problems (i.e. remove sliding friction solves the wall problem, but then when static friction is overcome as when the player is on a really steep slope, they just won't stop sliding). likewise implementation of sliding friction gets you where you are now.

-me

Share this post


Link to post
Share on other sites
Quote:
Original post by Palidine
2) zero friction, but when the player is in contact with the ground do not apply gravity. With this you get no sliding but you have to construct other mechanisms by which you prevent players from running up steep slopes (generally invisible collision planes)

I avoided this by only saying gravity doesn't apply if the slope is low enough to walk on. So if you hit a slope that is too steep, gravity applies and you slide down.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!