# Smooth character movements?

I've some problems moving my character using physics. It looks more like pulling up a big concrete block then an actually walking. Sometimes it even staggers so much it fells down. Very funny to see someone walking while lying on the ground. At least for me, but my players don't laugh.

My physics implementation is based on lesson 8. I extended it with sliding left and right and turning around (torque). My character I'm using for the tests is a box. In the final version it'll be represented to the physics engine as a box, too.

Anybody?

I never looked at the Physics-Engine cause I couldn't get it to run according to the netbeans+jme-tutorial (worked fine for the non-physics-part btw…)

but if you wanna just use it for gravity-purposes, you could simply use the basic physic-formula and implement it yourself:

Pseudo-Code:

a=9.8; // Acceleration Gravity on Earth, on moon it would be about 1.5 (in Meters per Square-Second)

// Given: a=(delta v)/(delta t)

// we know: a and delta t (time since last localtranslation and now)

// --> delta v = a * delta t (in seconds)

// wie know: v0 (speed at last localtranslation, starting at 0 when jumping over a cliff  ;))

// --> v1 = v0 + delta v

I would define a maximum speed to simulate wind-resistance, otherwise, the object would accelerate indefinitely. Realistic for a human beeing would be v = 50 (in Meters per Second, equals 180 Kilometers per Hour)

if (v1>50) { v1=50; }

now you simply have to calculate the distance your object made since the last localtranslation:

// Given: v = s / t

// v == velocity

// s == distance

// t == time (time since last localtranslation of the object)

// --> s = v * t

// --> s = v1 * delta t (in meters)

That's it!  8) (Theoretically, didn't try it myself yet)

Physics modeling is hard work. You need to identify what exactly you do not like about the current movement and what you'd like better. After that you can decide about a proper way to model your character physically. Probably you could go with a sphere (rolling) or you need a biped etc… or you just need other visual animation to have it 'feel' right…

What I don't like about my current physics situation: after applying a very weak force (0,0,2 for example) my character falls down.

If I use a sphere, my character would start rotating – not exactly what I'm searching for, unless you can make that it doesn't rotate with the physics sphere.

I don't know how to make a physics biped or whatever.

And please don't start throwing math at me  ;).

I'm going to not attach the player to the dynamic physics node, but instead moving it every update to the node's position. Maybe I can even implement a sphere on that way.

SeySayux said:

I'm going to not attach the player to the dynamic physics node, but instead moving it every update to the node's position. Maybe I can even implement a sphere on that way.

yes, that's a possibility

SeySayux said:

What I don't like about my current physics situation: after applying a very weak force (0,0,2 for example) my character falls down.

You should be able to avoid this easily by moving the center of mass down.

The sphere stuff didn't work: I could move the player great, but I couldn't anymore implement something to rotate it.

I'm going to try moving the center of mass even more down (It's currently at 0,0.5,0 already)

It worked! Hooraaaay! Thank you very much! I've been working months on this! But, I've still a question: If, it could still happen, the character falls down, I need something to get it back up. How can I detect whether it has fallen down, and how can I get it back up? Maybe I've to implement a joint to restrict it's rotation? How do I do this?

The easiest way is to move the center of mass down even more (to the outside of the geom). This results in a skipjack character.

It seems like I don't have to. I've tested, and the character can get up again with little effort. Maybe implementing invisible walls could give a solution to make sure it doesn't fall anymore.