I have a function that fires a ball in a direction. It gets it's direction depending on the angle between the ball and the mouse position. The issue is that currently if the mouse is further away from the ball, the ball goes faster, and if the mouse is closer, the ball goes slower. I want the ball to go the same speed no matter how far away the mouse is.
mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
trajectory = mousePos - new Vector2(aimPont.transform.position.x, aimPont.transform.position.y);
private void FireBall(Vector2 tra)
{
rb.AddRelativeForce(tra * speed);
}
↧