Lizzard Attack anim not wokring

Hi,

so i have created the animation and setup the isAttacking Parameters

when i drag the lizard into the scene and click on the bool Parameters checkbox i see the animation working from jump to walk then i click and the attack works. i have applied all to prefabs and deleted the one lizard out the scene. when i click play it walks through the gravestone no animation plays. i have the istrigger ticked on the lizzrd

my code is below

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Lizzard : MonoBehaviour
{

private void OnTriggerEnter2D(Collider2D otherCollider)
{
    GameObject otherObject = otherCollider.gameObject;
    if(otherObject.GetComponent<Defender>())
    {
        GetComponent<Attacker>().Attack(otherObject);
    }
}

}

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Attacker : MonoBehaviour
{
[SerializeField]
[Range(0f, 5f)]float currentSpeed= 2f;

[SerializeField]
GameObject currentTarget;

// Start is called before the first frame update


// Update is called once per frame
void Update()
{
    transform.Translate(Vector2.left * currentSpeed * Time.deltaTime);
}

public void SetMovementSpeed(float speed)
{
    currentSpeed = speed;
}


public void Attack(GameObject target)
{
    GetComponent<Animator>().SetBool("isAttacking", true);
    currentTarget = target;
}

}

am i missing something. no errors in the console

Hi all,

you may close this ticket, found the problem.

There was no rigid-body attached to my lizard. :slight_smile:

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms