Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void RotateBullet(Vector2 to)
- {
- Vector2 pos = bullet.transform.localPosition.normalized;
- float angle = Mathf.Atan2(pos.y - to.y, pos.x - to.x);
- Debug.Log($" position: {pos} direction: {to} angle: {angle}");
- float x = pos.x+ Mathf.Cos(angle) * radius;
- float y = pos.y + Mathf.Sin(angle) * radius;
- var desired = new Vector2(x, y);
- bullet.transform.localPosition = desired;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement