Jump to content
  • Advertisement
  • entries
  • comments
  • views

Jumping Beans

Sign in to follow this  



Just a quick post to say I've added jumping states to the PC state machine now, finishing off the very basic movement system.

If the character is running when the jump key is pressed, the machine switches directly to the PcState::Jump and the air velocity is the same as when running. If the player is walking or standing when the key is pressed, the machine goes first into the PcState::BeginJump state, which first plays a small crouching animation, then switches to PcState::Jump with the air velocity set to the same as when walking.

So you have standing/walking hops and running jumps in other words.

The state machine comes into its own as we add new behaviours, as the modifications needed to existing states were trivial and the overall flow is no more complicated.

void RunState::update(FrameParams ¶ms, Frame &frame, float delta){ if(data.controls.anyMovementDown()) { v = inputVector(params); } Vec3 t = data.kcc.position(); data.kcc.move(frame.physics, v * data.settings.runSpeed * delta, threshold); setRotation(v, 0.1f); if(vectorLength(t - data.kcc.position()) < threshold) { machine.setNextState(PcState::Idle); } else if(data.controls.down(PcControls::Jump)) { data.settings.airSpeed = data.settings.runSpeed; machine.setNextState(PcState::Jump); } checkFall();}Not too sure what I'm going to tackle next, but thinking about starting the rag doll system now. That was the main reason for integrating Bullet into this version, so would be good to start doing things I couldn't do in the last version due to the limitations of my own physics system.

I've just finished up some quick draft code to generate capsules based on the skeleton structure and a given maximum radius.


Hoping that I can use this, with a couple of extra parameters - hand and foot length and head radius for example - to generate the bodies for the ragdoll quite easily. Works in principle anyway.

The idea is to take two points and pass them to a method that returns an aligned capsule. For those who are interested:

LocatedShape *LocatedShape::alignedCapsule(const Vec3 &a, const Vec3 &b, float radius){ Vec3 d = b - a; float height = vectorLength(d); if(radius > height / 2) radius = height / 2; Capsule *sh = new Capsule(radius, height); Vec3 c = a + (d * 0.5f); Quaternion q = rotationToQuaternion(Vec3(0, 1, 0), d); Matrix m = rotationMatrixFromQuaternion(q) * translationMatrix(c); return new LocatedShape(sh, m);}Where LocatedShape is just an aggregation of a Shape* and a transform, a temporary class to use until I'm ready to start adding these as actual physics bodies. I then just walk the skeleton, finding parent-child relationships and passing their transformed positions (based on current key frame and player world transform) to this method, drawing then discarding the LocatedShapes.

Thanks for stopping by.
Sign in to follow this  


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • 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!