Hello there. I started to learn unity about 1 week ago. I’ve done my player controller with animation, so it works clearly.
Now I want to add boss animation when the player touches the Trigger. But it doesnt work. The boss (robot) is flipping (its work correctly) but his animation (SunJacking) doesn’t play. I’ve done the transition between “Any State” and “SunJacking”. The bool parameter has been done too (came). I’ve tried to use “SetBool” and “anim.Play” too. So here is my code. Hope you will help me with my learning x).
Best wishes, Awaking
using UnityEngine;
public class SunChap1 : MonoBehaviour
{
public GameObject player;
public GameObject robot;
private Animator anim;
private Animation an1;
void Start()
{
anim = GetComponent<Animator>();
an1 = GetComponent<Animation>();
}
void OnTriggerEnter2D(Collider2D other)
{
if (other.tag == "Player")
{
Flip(robot);
// anim.SetBool("Came", true); //my first try
// anim.Play("SunJacking"); //my second try
}
}
void Flip(GameObject robot)
{
Vector2 theScale = transform.localScale;
theScale.x = 1;
robot.transform.localScale = theScale;
}
}