- Home /
Projectile moving in a angular direction
I am trying to fire a projectile in an angled direction with some speed. Currently, i am doing it by using rigidBody.AddForce
and internal logic of increasing and decreasing x and y speed.
Below is my code:
if(speedY >=5 && speedY <= 10 && !limitReached)
{
transform.rigidbody.AddForce(speedX, speedY ,0.0f);
transform.Rotate(new Vector3(100,0,0) * Time.deltaTime);
speedY += 0.3f;
}
else
{
limitReached = true;
transform.rigidbody.AddForce(speedX, speedY ,0.0f);
transform.Rotate(new Vector3(100,0,0) * Time.deltaTime);
speedY -= 0.3f;
}
I find this very crude and want to use EulerAngles and Quaternion functions to move the projectile in a direction and come down as well. But i am not able to figure out anything rather i am very unclear about them. The documentations doesn't talk much apart from few lines.
How can i specify an angle so that the projectile is fired at that angle. How does it make sense ? For example, i say Quaternion.EulerAngle(0,0,45)
then how the angle is created and how does it get applied to the transform ?
It would be great to get some explanation which would clear my concepts.
Your answer

Follow this Question
Related Questions
c# modify only one axis of a quaternion 2 Answers
What is the difference between Quaternion.Euler and Quaternion.eulerAngles? 2 Answers
Need help with Quaternions - Making a VR Combination Lock 1 Answer
Transform.Rotate producing unexpected results when being used after setting localEulerAngles 0 Answers
How do I AddForce in the forward direction of another object? 2 Answers