AddForce doesn't work when used with velocity

Hi, I’m very new to Unity and I can’t get around this weird problem. I have a top down iOS game where you roll a ball around using the accelerometer and then tap to jump. I’m using rigidbody.AddForce to jump in the Y direction and the rolling movement is on the XZ plane.

What happens is that when I tap, the ball jumps but not that high and it falls to the ground very slowly. This is very odd because if I use rigidbody.AddForce() instead of rigidbody.velocity to roll the ball around, the jump works really well and it also jumps higher than before. Any ideas about what’s going on here? I double checked my colliders and Rigidbody settings and all seems fine, and it even works if I don’t use rigidbody.velocity, but I feel that’s the best way to roll the ball around in the game so I have to use it.

BTW, the reason I use GetMouseButton(0) is so that I can try it out the jump in the Editor with my mouse. Same command accepts iOS touch also.

Any help is appreciated,

This is my code:

moveDirection.x = Input.acceleration.x;
moveDirection.z = Input.acceleration.y;

if (moveDirection.sqrMagnitude > 1f)
rigidbody.velocity = moveDirection * Time.fixedDeltaTime * moveSpeed * speedFac;


if (Input.GetMouseButton(0))
	if (isGrounded)
		rigidbody.AddForce(0f, jumpforce * Time.FixedDeltaTime, 0f, ForceMode.Impulse);
		isGrounded = false;

I may have solved my Issue (for those interested) - Use AddForce and ForceMode.VelocityChange

I will post a reply once I’ve tested it but right now that seems like my best option.

velecity overrides add force and physics. it’s a higher level than physics commands like force. if a button goes down to addforce, then say if addforce down, not set velocity values.

In most cases you should not modify the velocity directly, as this can result in unrealistic behaviour. Don’t set the velocity of an object every physics step, this will lead to unrealistic physics simulation. A typical example where you would change the velocity is when jumping in a first person shooter, because you want an immediate change in velocity.

If you @smokenstein want more info on this and a better solution then check out this.