I am not sure were to look to solve this. Every time I click on my player he rotates. I am not sure when this started. I just noticed it when I added my cinemachine camera. I tried deleting the camera, and disabling the capsule collider. Behavior makes it nearly impossible to hit the enemies. Any Ideas where I should look.
using RPG.Movement;
using RPG.Combat;
using RPG.Core;
using UnityEngine;
using System;
namespace RPG.Control
{
public class PlayerController : MonoBehaviour
{
Mover mover;
Fighter fighter;
Health health;
void Start()
{
mover = GetComponent<Mover>();
fighter = GetComponent<Fighter>();
health = GetComponent<Health>();
}
void Update()
{
if (health.IsDead()) return;
if (InteractWithCombat()) return;
if(InteractWithMovement()) return;
}
private bool InteractWithCombat()
{
RaycastHit[] hits = Physics.RaycastAll(GetMouseRay());
foreach (RaycastHit hit in hits)
{
CombatTarget target = hit.transform.GetComponent<CombatTarget>();
if (target == null) continue;
if (!fighter.CanAttack(target.gameObject)) continue;
if (Input.GetMouseButton(0))
{
fighter.Attack(target.gameObject);
}
return true;
}
return false;
}
private bool InteractWithMovement()
{
RaycastHit hit;
bool hasHit = Physics.Raycast(GetMouseRay(), out hit);
if (hasHit )
{
if (Input.GetMouseButton(0))
{
mover.StartMoveAction(hit.point, 1f);
}
return true;
}
return false;
}
private static Ray GetMouseRay()
{
return Camera.main.ScreenPointToRay(Input.mousePosition);
}
}
}
![Screenshot 2022-12-18 092000|203x500](upload://oLv2LAoKeEHN0ohGQamlT1V5S41.png)