I’m having a weird problem to animate a character in my project. For reference, the character, an enemy in the game, has three animations: “Idle” (not really an animation, but that’s how the character stays when the player’s not around), “ArmMoving” (for when the player is coming closer to the enemy) and “Karate” (when the player is even closer to the enemy).
For the transition from “Idle” to “ArmMoving”, a bool, called “NearPlayer” was created. If true, the “ArmMoving” animation starts, if false, it goes back to “Idle”.
And the, for the transtion from “ArmMoving” to “Karate”, I created another bool, “DangerArea”, same scheme as before: if true, “Karate” starts, if false, goes back to “ArmMoving”.
Looks fine, right? Well, for some reason, none of the animations play when I playtest the game, even if I turn all the bools on.
EDIT: I added a new bool, called “inIdle”, and now this boll needs to be “false” for “Idle” to transit to “ArmMoving”, and “true” for the reverse, I also made an script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class RollController : MonoBehaviour
{
static Animator anim;
// Start is called before the first frame update
void Start()
{
anim = GetComponent<Animator>;
}
// Update is called once per frame
void Update()
{
if(Vector3.Distance(player.position, this.transform.position) < 10)
{
Vector3 direction = player.position - this.transform.position;
direction.y = 0;
anim.SetBool("isIdle", false);
if(direction.magnitude >= 5)
anim.SetBool("NearPlayer", true);
anim.SetBool("isIdle", false);
}
if(direction.magnitude > 3)
{
anim.SetBool("DangerArea", true);
}
else
{
anim.SetBool("isIdle", false);
anim.SetBool("NearPlayer", false);
anim.SetBool("DangerArea", false);
}
}
}
}
I’m now getting the error “Type or namespace definition, or end-of-life expected”.