Click here to Skip to main content
15,845,212 members
Please Sign up or sign in to vote.
3.33/5 (3 votes)
See more:
I'm making a mod for a game, and I want to make the character move faster, and jump higher. (Not at the same time, basically looking to make a super speed mod + super jump mod.)

I have access to the players position(Vector3), heading(in degrees), the players movement velocity in Vector3, and the ability to apply "force" to any direction I want(Vector3) on the player object.

So, these should be all I need, but, I can't figure the math out.

I figure for super speed, I could create an imaginary point in vector space along the players heading, and move the player towards the point, and have the point recalculate every frame, so the player never reaches it.

Then I can do something like this.

Player.Character.Velocity = Vector3.Normalize(ImaginaryPoint.Position - Player.Character.Position) * 5.0F

But, I can't figure out how to create my imaginary point. (I suppose one could use the heading to directly calculate\influence velocity as well.. But, I have no clue which formula I'm after.)

Jumping, is roughly the same thing, a slight boost for directional velocity + force applied to the Z axis should accomplish my goal.

At the moment, I have this primitive version of jumping implemented, it does indeed jump, but, it needs more directional velocity.

if (Game.isGameKeyPressed(GameKey.Jump))
    Player.Character.ApplyForce(new Vector3(0, 0, 50), new Vector3(0, 0, 0)); // ApplyForce(V3 pos, V3 rot);
    // Game.DisplayText(Player.Character.Heading.ToString());

So, can anyone help me out here?
Updated 11-May-12 10:54am

1 solution

Well, I came up with a generic solution, since I already have the players current velocity, I can just take that, add a multiplier(ie, Velocity * 10), and apply the result as an additional force.

This probably isn't ideal, but, it saves me some math, since the current velocity already accounts for proper heading, etc,. ;)

(I would still welcome a better solution though.)
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900