So, I made a script that would make my player look at the mouse.position if you held down left click, and that function works fine. I also made it so when you lifted the mouse button it would launch. No matter what I do, it will keep moving up in world space, but I need it in local space. Heres my code:
private void LookAtMouse() {
if (_charging) {
Vector3 _mousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
direction = new Vector3(_mousePosition.x - transform.position.x, _mousePosition.y - transform.position.y,0);
transform.up = direction;
} else {
//transform.rotation = Quaternion.Euler(0,0,0);
}
}
private void Launch() {
Debug.Log(_launchMultiplier);
if (Input.GetMouseButtonDown(0)) {
_anim.SetTrigger("Charge");
_charging = true;
StartCoroutine(PowerLaunch());
} else if (Input.GetMouseButtonUp(0)) {
_anim.SetTrigger("Launch");
_rb.AddForce(transform.up * launchSpeed * _launchMultiplier);
_charging = false;
_launchMultiplier = 0;
}
}