Hello,
I need to get the angle of a gameObject so i can use it to shoot a projectile
in the same direction.
Vector2 force = new Vector2(Mathf.Cos(angle * Mathf.Deg2Rad), Mathf.Sin(angle * Mathf.Deg2Rad)) * bulletSpeed;
projectile.rigidbody2D.velocity = force;
This is the snippet I plan to use to shoot the newly created projectile and when i enter a angle, like 90, 45, 270 or some other value it seems to fire correctly.
Now I “just” have to get the angle automatically from an object named spawn that is the child of a object that rotates (so I guess local coordinates/angels won’t work).
How would I go about doing this? I have been at it for hours now…
Thanks in advance!