I am working on a character controller for a 2d-platformer I am using Unity3D to implement it using my own physics (not the standard physics and the RigidBody2D component), anyway I finished it mostly but the problem is the jump, it is satisfying but I want the character to stay a little bit longer in the air when it reaches the peak of the jump, but without using a timer or so, what I mean by that, I want the character to raise slower when it gets close to the jump peak, so the jump curve gets wider.
The way I handle the velocity and movement is so: - I have a Vector2 velocity that represent the current velocity, it is set each frame depending on the current state of the character(Walking, Running, Idle,...) - I have a float gravity which is a fixed float representing the gravity - When the player jumps, I set its velocity.y to jumpVelocity and each frame, I subtract (gravity * Time.DeltaTime) from it.
The jump curve I get:
The jump curve I want:
Anyway easy way (Changing a factor or adding a variable or so) to achieve that without rewriting 50% of my code? Thanks in advance :)
With (gravity*time^2) as mentioned in the comments:
gravity
andjumpVelocity
– Ruzihm