loadingsolo.blogg.se

Skyrim set jump height
Skyrim set jump height






skyrim set jump height

VelocityY = -6.0f // Limit the speed of ascent If(velocityY < -6.0f) // If character is still ascending in the jump

skyrim set jump height

You could add something like: void OnJumpKeyReleased() In this case you'll need to handle both pressing and releasing the jump key. Important You don't want to be able to start a jump if your character is not on the ground, so you'll need to add a check for that.īut games like Mario and Sonic have a variable jump where the height of the jump depends on how long you press the button down. VelocityY = -12.0f // Give a vertical boost to the players velocity to start jump This will make the character start rising, while gravity will automatically take care of bringing him down: void OnJumpKeyPressed() Now the easiest way to implement a jump that always has the same height, no matter how long you press the key, is simply to change the vertical velocity once. VelocityY += gravity * time // Apply gravity to vertical velocity PositionY += velocityY * time // Apply vertical velocity to X position PositionX += velocityX * time // Apply horizontal velocity to X position In particular, you need position, velocity, and gravity defined, and your update loop should be doing something roughly similar to this (collision detection and response omitted for simplicity): float positionX, positionY // Position of the characterįloat velocityX, velocityY // Velocity of the characterįloat gravity = 0.5f // How strong is gravity What I'll describe below is just one of the possibilities.įirst you need some basic physics variables and calculations on your update loop. Also, there are numerous ways to implement this, depending on a lot of factors. And although the underlying API might have some differences from DirectX, that has nothing to do with jumping, so the same tutorials or answers should apply here. First of all, XNA also uses C# too so it's the same programming language.








Skyrim set jump height