'Enemy' AnimationEvent 'Step' on animation 'Walk' has no receiver! Are you missing a component?

I have a problem with a script which should make an enemy follow a player when he enters enemy’s collider, but it doesn’t work.
Code (CSharp):

  • void Update()
  • {
  • if (isAlive && isTargetInReach)
  • {
  • followPlayer();
  • }
  • if (isAlive)
  • {
  • anim.SetBool(“isWalking”, agent.hasPath);
    • }
  • Roam();
  • }

As like in the code above, when isAlive and isTargetInReach are true, enemy should follow player. If I remove isTargetInReach, it follows. But the code below which is applied to body of enemy and where “Enemy” is placed into Movement, doesn’t even set isTargetInReach true.

Code (CSharp):

  • using System.Collections;
  • using System.Collections.Generic;
  • using UnityEngine;
    • public class ColliderData : MonoBehaviour
  • {
  • public EnemyMovement movement;
    • private void OnTriggerEnter(Collider other)
  • {
  • if(other.gameObject.tag == “Player”)
  • {
  • movement.isTargetInReach = true;
  • }
  • }
  • private void OnTriggerExit(Collider other)
  • {
  • if (other.gameObject.tag == “Player”)
  • {
  • movement.isTargetInReach = false;
  • movement.GoBackToStartingPosition();
  • }
  • }
  • }

I checked, every tag is correct.
What could go wrong, tho?

That actually sounds like an animation issue not a navigation issue.
Your animation “Walk” has an Animation Event (called “Step”). This warning is indicating that your Enemy object does not have the method that the Step Animation Event is trying to call Implemented on any component. You can resolve it by either removing that Animation Event, or implementing whatever “Step” is trying to do on a MonoBehaviour attached to your Enemy GameObject

I forgot to change the title, but the thing in this thread is about the follow player function not working with a sphere collider applied to enemy.

You are totally right, my apologies. I read the title and code but didn’t read what you said in the post very closely.

Regarding the issue you’ve mentioned in the post. It sounds like a physics configuration issue. Perhaps your ColliderData’s Collider is not set to IsTrigger, or if your Player does not have a RigidBody component, the OnTriggerEnter will not be called.
Another possibility is that the Physics layer of your ColliderData GameObject does not intersect with your Player GameObject’s layer.

You can see if the OnTriggerEnter is called by putting a Debug.Log statement with the other.name to have Unity log the names of all GameObjects that trigger that function. If your Player never triggers it, it’s probably one of the two above issues.