MoustafaChamli Posted November 6, 2014 Posted November 6, 2014 We're making some motion changes due to the nature of the game, and one of them affects jumping. Right now, it's set up to use a static variable called "JUMPBOOST". We'd like to change that to use the character's current velocity to affect his jump distance (as we have three moving speeds). if (inputInfo->jumpDown && !_model[currentWorld]->GetAirborne()) { jump = JUMPFORCE; homeBaseMovement->z = homeBaseMovement->z * JUMPBOOST; anim = Animation_type::run_jump_rise; isJumping = true; moveType = Move_type::jumping; } We've looked into using GetVelocity, but can't seem to figure what's missing to apply it properly. Quote
whiterabbit Posted November 6, 2014 Posted November 6, 2014 You need to get the 'length' of their velocity, that will tell you how fast they are moving. You could then multiply JUMPBOOST by that value, but you should probably limit the multiplier to a certain range. I don't know how you do it in C but Lua is easy. local Velocity = ent:GetVelocity() local Speed = Velocity:GetLength() local JumpPower = JUMPBOOST*Speed; --todo: if Speed is 0, what will you do? 1 Quote
macklebee Posted November 6, 2014 Posted November 6, 2014 the GetLength() method is just for sounds... for Vec3's, its Length() so it would be: local Speed = Velocity:Length() 1 Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel
MoustafaChamli Posted November 6, 2014 Author Posted November 6, 2014 Thanks for your answers guys, but this is a C++ question. Quote
gamecreator Posted November 6, 2014 Posted November 6, 2014 Not hard to convert. I believe this would be the C equivalent. Vec3 Velocity = entity->GetVelocity(); float Speed = Velocity->Length(); float JumpPower = JUMPBOOST*Speed; //todo: if Speed is 0, what will you do? edit: whoops. That's what I get for trying this at work. Thanks macklebee. 1 Quote
macklebee Posted November 6, 2014 Posted November 6, 2014 Velocity is a Vec3... 1 Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel
MoustafaChamli Posted November 6, 2014 Author Posted November 6, 2014 I think gamecreator is on to something. If I use this: float Velocity = _model[currentWorld]->GetVelocity().z; It seems to work, up to a point. When we reach maximum speed, the character actually jumps backwards! If I try to compile with the following, though: float Velocity = _model[currentWorld]->GetVelocity().z; float Speed = Velocity->Length(); It returns that the base operand of '->' (on the second line) is not a pointer. Quote
MoustafaChamli Posted November 6, 2014 Author Posted November 6, 2014 *headdesks* After having changed with how the jump mechanic was working (as originally programmed), I came to the realization that this calculation wasn't needed. I think we can consider this topic closed. Quote
Rick Posted November 6, 2014 Posted November 6, 2014 as we have three moving speeds I was thinking if you have 3 moving speeds and know those speeds and what speed a character is in you can just hardcode the jump boost based on those 3 speeds. speed 1 = 5 boost, speed 2 = 7 boost, speed 3 = 10 boost or something. Quote
gamecreator Posted November 6, 2014 Posted November 6, 2014 I think gamecreator is on to something. To be completely honest, I don't even follow the code. I just converted whiterabbit's & macklebee's Lua to C. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.