I have a code where I do the movement of a character (specifically a tiger) somewhere I get this error CS0246: Could not find type or namespace name ‘AnimationsTigerMAMA’ (missing a usage directive or assembly reference ?) I already reviewed it but I really don’t understand it, can someone help me
This my script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using System.Threading.Tasks;
public class PlayerMovementTigreMAMA : MonoBehaviour
{
[SerializeField] private Rigidbody _rb;
[Header(“Movement values”)]
public float _movementSpeed;
[SerializeField] private float horizontalMovement;
[SerializeField] private float verticalMovement;
[SerializeField] private float rotationSpeed;
float startSpeed;
float runSpeed;
bool isRotating;
[SerializeField] bool isAnotherPlayer;
[Header(“Animations”)]
[SerializeField] private Animator animator;
[SerializeField] LayerMask groundLayer;
[SerializeField] float gravity;
[SerializeField] float turnSmoothVelocity;
[SerializeField] float _smoothRotation;
AnimationsTigerMAMA animationsPlayer;
public Transform cam;
float targetAngle;
float angle;
public Vector3 direction;
private void Start()
{
animationsPlayer = FindObjectOfType();
startSpeed = _movementSpeed;
runSpeed = startSpeed * 1.3f;
}
private void Update()
{
if (Input.GetKey(KeyCode.T))
{
direction += new Vector3(0, 0, 1);
}
if (Input.GetKeyUp(KeyCode.T))
{
direction -= new Vector3(0, 0, 1);
}
if (Input.GetKey(KeyCode.G))
{
direction += new Vector3(0, 0, -1);
}
if (Input.GetKeyUp(KeyCode.G))
{
direction += new Vector3(0, 0, 1);
}
if (Input.GetKey(KeyCode.F))
{
direction += new Vector3(-1, 0, 0);
}
if (Input.GetKeyUp(KeyCode.F))
{
direction += new Vector3(1, 0, 0);
}
if (Input.GetKey(KeyCode.H))
{
direction += new Vector3(1, 0, 0);
}
if (Input.GetKeyUp(KeyCode.H))
{
direction -= new Vector3(1, 0, 0);
}
direction = new Vector3(Mathf.Clamp(direction.x, -1, 1), 0, Mathf.Clamp(direction.z, -1, 1));
Vector3 newDirection = direction;
targetAngle = Mathf.Atan2(newDirection.x, newDirection.z) * Mathf.Deg2Rad + cam.eulerAngles.y;
angle = Mathf.SmoothDampAngle(transform.eulerAngles.y, targetAngle, ref turnSmoothVelocity, _smoothRotation);
if (direction.x != 0 || direction.z != 0)
Move(newDirection);
else if (direction.x == 0 || direction.z != 0)
{
if (!animationsPlayer.isPlayingAnimation && animationsPlayer.isAWalkingAnimation == false)
{
animator.Play(“Idle_A”);
}
}
newDirection.y += gravity * Time.deltaTime;
}
Vector3 GetAlignment()
{
RaycastHit hit;
RaycastHit hit2;
RaycastHit hit3;
RaycastHit hit4;
if (Physics.Raycast(transform.position + new Vector3(0.04f, 0.2f, 0.07f), -transform.up, out hit, 0.7f, groundLayer) ||
Physics.Raycast(transform.position + new Vector3(0.04f, 0.2f, -0.12f), -transform.up, out hit2, 0.7f, groundLayer))
{
Physics.Raycast(transform.position + new Vector3(0.04f, 0.2f, 0.07f), -transform.up, out hit, 0.7f, groundLayer);
Physics.Raycast(transform.position + new Vector3(0.04f, 0.2f, -0.12f), -transform.up, out hit2, 0.7f, groundLayer);
Physics.Raycast(transform.position + new Vector3(-0.04f, 0.2f, 0.07f), -transform.up, out hit3, 0.7f, groundLayer);
Physics.Raycast(transform.position + new Vector3(-0.04f, 0.2f, -0.12f), -transform.up, out hit4, 0.7f, groundLayer);
Vector3 newUp = (hit.normal + hit2.normal + hit3.normal + hit4.normal).normalized;
newUp -= new Vector3(0f, 0.7f, 0f);
return newUp;
}
return Vector3.zero;
}
private void Move(Vector3 direction)
{
if (animationsPlayer.isAWalkingAnimation == false)
animator.Play(“Run”);
_movementSpeed = runSpeed;
var matrix = Matrix4x4.Rotate(Quaternion.Euler(0, targetAngle, 0));
var newInput = matrix.MultiplyPoint3x4(direction);
transform.position += newInput * _movementSpeed * Time.deltaTime;
var newInputRotation = matrix.MultiplyPoint3x4(direction);
if (newInputRotation.z >= 0.1f || newInputRotation.x >= 0.1f || newInputRotation.x <= -0.1 || newInputRotation.z <= -0.1)
{
float targetAngle2 = Mathf.Atan2(newInputRotation.x, newInputRotation.z) * Mathf.Rad2Deg;
float angle2 = Mathf.SmoothDampAngle(transform.eulerAngles.y, targetAngle2, ref turnSmoothVelocity, _smoothRotation);
RaycastHit info;
if (Physics.Raycast(transform.position + new Vector3(0.04f, 0.2f, 0.07f), -transform.up, out info, 0.4f, groundLayer))
{
transform.rotation = Quaternion.Lerp(transform.rotation, QuaternionLookRotation(transform.forward, GetAlignment()), 10 * Time.deltaTime);
transform.rotation = Quaternion.Lerp(transform.rotation, Quaternion.Euler(0, angle2, 00), 10 * Time.deltaTime);
}
else
{
transform.up = Vector3.up;
}
}
}
private void OnDrawGizmos()
{
Debug.DrawRay(transform.position + new Vector3(0.04f, 0.2f, 0.07f), -transform.up * 1f, Color.red);
Debug.DrawRay(transform.position + new Vector3(0.04f, 0.2f, -0.12f), -transform.up * 1f, Color.red);
Debug.DrawRay(transform.position + new Vector3(-0.04f, 0.2f, 0.07f), -transform.up * 1f, Color.red);
Debug.DrawRay(transform.position + new Vector3(-0.04f, 0.2f, -0.12f), -transform.up * 1f, Color.red);
}
Quaternion QuaternionLookRotation(Vector3 approximateForward, Vector3 exactUp)
{
Quaternion zToUp = Quaternion.LookRotation(exactUp, -approximateForward);
Quaternion yToz = Quaternion.Euler(90, 0, 0);
return zToUp * yToz;
}
}