Thanks so much for answering so quickly!
I’ll take another screenshot and share it below, please let me know if you need any other info:
As for the code, I have this in the sword.cs:
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Rendering;
public class Sword : MonoBehaviour
{
private PlayerControls playerControls;
private Animator animator;
private PlayerController playerController;
private ActiveWeapon activeWeapon;
private void Awake()
{
playerController = GetComponentInParent<PlayerController>();
activeWeapon = GetComponentInParent<ActiveWeapon>();
animator = GetComponent<Animator>();
playerControls = new PlayerControls();
}
private void OnEnable()
{
playerControls.Enable();
}
// Start is called before the first frame update
void Start()
{
playerControls.Combat.Attack.started += _ => Attack();
}
private void Update()
{
MouseFollowWithOffset();
}
private void Attack()
{
animator.SetTrigger("Attack");
}
private void MouseFollowWithOffset()
{
Vector3 mousePos = Input.mousePosition;
Vector3 playerScreenPoint = Camera.main.WorldToScreenPoint(playerController.transform.position);
float angle = Mathf.Atan2(mousePos.y, mousePos.x) * Mathf.Rad2Deg;
if (mousePos.x < playerScreenPoint.x)
{
activeWeapon.transform.rotation = Quaternion.Euler(0, -180, angle);
} else
{
activeWeapon.transform.rotation = Quaternion.Euler(0, 0, angle);
}
}
}