applying force to a rigidbody while keeping magnitude the same

I would like to apply a sideways force to a ball bouncing off a plane that increases the closer to the edge of the plane (I am okay with that part I think!), but when I add the force I want to keep the overall magnitude of the ball the same. How can you do that?

Should the applying interval increase or the force itself? If i m not mistaken the force is set by the magnitude so so increasing the force itself wouldn’t make much sense. And if its the interval i don see any problem because it isn’t linked to magnitude?
Maybe i just don’t understand the question.

To direclty answer the question:
Get the direction vector (however you need to)
Normalize to make the vector length 1
multiply up the required magnitude
apply force

Force in a direction of specific magnitude… But yeah i dont really get the Q either

Thanks for trying to answer my question.

Basically i have ball bouncing around in a frictionless environment so it never loses energy. I have a flat plane. When it bounces closer to the edge of the plane I want to apply a force like the plane was on an angle (but it isn’t) so it bounces off in that direction.

Does that make it any easier to understand?

sure.
Not sure how you are applying force to the ball, but you could simply apply an impulse force to the ball at said moment. So it gives a burst of velocity to the ball at any point.

That is what i want to do, but i don’t want to speed the ball up.

If I understand this correctly, you want the ball to change direction based on the direction of a given force but maintain the same absolute velocity?
Then what you want to do is something like this.

public Vector3 GetNewVelocity(Vector3 ForceDirection,Vector3 CurrentVelocity)
	{
		float velocityMagnitude=CurrentVelocity.magnitude;//store magnitude of current velocity
		Vector3 newVelocity=ForceDirection.normalized*velocityMagnitude;//create new velocity vector in the direction (normalized) of Force with magnitude of velocity
		return newVelocity;
	}

Hope this helps.
cheers
Empo

That is correct, thank you :slight_smile:

I will give this a try.

did that do the trick for you?