I have went through this lesson multiple times, and am unable to catch what I am doing wrong. The animation auto plays and doesn’t work with the left mouse button that I set as the trigger. How do I fix this?
Things I have done:
Set Binding to Left Button Mouse
Unchecked Has Exit Time and 0 Duration for three transitions
Added Conditions
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Sword : MonoBehaviour
{
private PlayerControls playerControls;
private Animator myAnimator;
private void Awake()
{
myAnimator = GetComponent<Animator>();
playerControls = new PlayerControls();
}
private void OnEnable()
{
playerControls.Enable();
}
void Start()
{
playerControls.Combat.Attack.started += _ => Attack();
}
private void Attack()
{
//fire our sword animation
myAnimator.SetTrigger("Attack");
}
}
When I have the Sword game object selected it only shows the Base Layer. After I add another layer and put the base layer with all of the animation elements under it, it doesn’t auto play, but then it also doesn’t work when I click the left mouse button. So possibly progress.
Can you share the inspector on the transition from the Entry State (the orange one) to the Swing Down animation? Additionally, set’s see the Parameters tab of the Animator rather than the Layers tab. We really won’t be using the Layers tab in this animator as the Layers are really more suited for working with 3d Skinned Mesh skeletons.
I have switched the binding to my spacebar and that is working! So looks like it has something to do with the Left Mouse binding that is not working.
Last update: I figured out the mouse issue. Since I was in Simulator and chose phone it wasn’t registering a mouse because phones don’t have one facepalm
Thank you for the trigger information as that fixed the first issue. Appreciate y’all taking your time again with this.