so i’ve got a very basic game, in which I have a basic enemy and player sprite. The problem is that even though the attack animation makes the “graphics” compnent of it go up in relation to the parent, it doesn’t do so. Everything else works though.
Heres the script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Enemy : MonoBehaviour
{
private GameObject wayPoint;
private Vector3 wayPointPos;
public float speed;
Animator anim;
bool CanMove;
void Start()
{
wayPoint = GameObject.Find("wayPoint");
anim = gameObject.GetComponent<Animator>();
anim.ResetTrigger("Attack");
CanMove = true;
}
void FixedUpdate()
{
if (CanMove)
{
wayPointPos = new Vector3(wayPoint.transform.position.x, transform.position.y, wayPoint.transform.position.z);
transform.position = Vector3.MoveTowards(transform.position, wayPointPos, speed * Time.deltaTime);
transform.LookAt(wayPointPos);
}
}
void OnTriggerEnter(Collider other)
{
if (CanMove)
{
Debug.Log("Attack");
anim.SetTrigger("Attack");
StartCoroutine(Attack());
}
}
IEnumerator Attack()
{
CanMove = false;
anim.SetTrigger("Attack");
yield return new WaitForSeconds(1);
CanMove = true;
anim.ResetTrigger("Attack");
}
}
I have a box collider, rigidbody, and a trigger box collider.
Thanks in advance!