So, I currently have this script:
using UnityEngine;
using UnityEngine.InputSystem;
public class BaseWeapon : MonoBehaviour
{
private PlayerInputActions Controls;
private PlayerInput input;
private void Awake()
{
this.Controls = new PlayerInputActions();
this.Controls.Player.RotateWeapon.performed += ctx => this.RotateHandler(ctx.ReadValue<Vector2>());
}
private void RotateHandler(Vector2 mousePosition)
{
Vector3 Position = Camera.main.ScreenToWorldPoint(mousePosition);
this.gameObject.transform.position =
this.gameObject.transform.parent.transform.position +
(Position - this.gameObject.transform.parent.transform.position).normalized;
}
private void OnEnable()
{
this.Controls.Enable();
}
private void OnDisable()
{
this.Controls.Disable();
}
}
And I'm trying to make it so the child object will rotate around the parent object in a circle. I tried clamping the radius of the movement, but I got insanely weird results. This is what it currently looks like:
https://dl.dropboxusercontent.com/s/tmcjkod07cjza0a/Unity_b0HTo3JVvl.mp4
Does anyone have any suggestions for making this work? Thank you in advanced.