Hello! I’m prototyping a 2D 1v1 fighting game and i wanted to include a boomerang ability in the project but I need some help. The help needed is actually about this piece of code :
destination = new Vector2(transform.position.x - boomerang.transform.position.x, transform.position.y - boomerang.transform.position.y);
boomerang.GetComponent<Rigidbody2D>().velocity = destination * projectileSpeed;
I would like that the boomerang keeps a constant speed but still goes in the correct direction. By that I mean that the speed of the boomerang should not be affected by the distance between the player and it but only by the projectile speed variable. The difference between the player’s and the boomerang’s position should be only used to show the boomerang where it is supposed to go. I’ve already tried some ways to fix it but none of them actually worked.
If you coul help me I would be very pleased, thanks