I am going to make a 2D game. I want to input angle and speed in the inspector. Then the ammo spawner can shoot the ammo in specific velocity. But I how can I set the ammo’s velocity?
For example, I input 30° and speed 100, and ammo will be shoot with 30° and 300 speed.
Good day.
How you will move the bullet? With rigidbody and addforce? or maybe by changing its transform.position?
Anyway, once you have a vector, you can change its magnitude if you reduce that vector to magnitude 1 (with Vector3.normalized) and then multiply this vector for a number.
Something like this:
Vector3 MyNewVector = new Vector3(10, -12, 20);
MyNewVector = MyNewVector.normalized;
MyNewVector = MyNewVector * 5;
//So now i have a vector with lenght (magnitude) 5 in the same direction as the vector (10, -12, 20)
This is how you can easy control direction and magnitude of a vector
Bye!