Quantcast
Channel: Questions in topic: "addforce"
Viewing all articles
Browse latest Browse all 1264

Keep Rigidbody velocity no matter the trajectory.

$
0
0
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); }

Viewing all articles
Browse latest Browse all 1264

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>