(3D)So when my player jumps it goes 10 m up into the air.When a player moves , a new force is added,which reduces the jump because of a simple line of code, this being
```cs
//Ground Check
IsGrounded = Physics.Raycast(Character.transform.position, Vector3.down, PlayerHeight * 0.5f + 0.2f, GroundLayer);
//Rigidbody
Vector2 Direction = MovementV2.ReadValue<Vector2>();
//Drag
if (IsGrounded)
{
Rigidbody.linearDamping = GroundDrag;
}
else
{
Rigidbody.linearDamping = 0;
}
//Force
float YVel = Rigidbody.linearVelocity.y;
Vector3 Z = Direction.x * Character.transform.right;
Vector3 X = Direction.y * Character.transform.forward;
Vector3 ForceDirection = (Z + X) * MovementSpeed;
ForceDirection.y = YVel;
if (IsGrounded == true)
{
Rigidbody.AddForce(ForceDirection.normalized * 10f, ForceMode.Force); //Here is the problem
if (CanJump == false)
{
CanJump = true;
}
if (CurrentJumps > 0)
{
CurrentJumps = 0;
}
}
else
{
Rigidbody.AddForce(ForceDirection.normalized * 10f * AirForce, ForceMode.Force); //Maybe its here too, AirForce is the slowness the player will get in the air so they aren't faster jumping than walking
}```
How could I make movement without affecting the jumping?(this being adding the up direction * Jumping power as a force)
Video:
Firsts jumps are me without moving, the others are while I move forward