Question by
MuttlyMartin · Dec 27, 2020 at 12:38 AM ·
animationunity 2dontriggerenter2d
my animtion plays when its not ment to too
iv got ontrigger systems to detect when my player comes in collion with this moveable object, but it plays as im stood on top of it. im using a trigger system to change a bool to play and not play the animtion when in the trigger , but it sometines plays as im on top of it? ``` using System; using System.Collections; using System.Collections.Generic; using UnityEngine;
public class MinecaftPressurePlate : MonoBehaviour { public Animator Player_animator;
public CapsuleCollider2D Player;
public float Move;
void Start()
{
GetComponent<MoveDamPlayer>().horizontalMove = Move;
}
void OnCollisionEnter2D(Collision2D collision)
{
if (collision.gameObject.tag == "Player")
{
Player.enabled = false;
}
}
void OnTriggerEnter2D(Collider2D collision)
{
if (collision.gameObject.tag == "Player")
{
Player.enabled = false;
Player_animator.SetBool("Pushing", true);
Debug.Log("ENTER");
}
}
void OnCollisionExit2D(Collision2D collision)
{
if (collision.gameObject.tag == "Player")
{
Player.enabled = true;
}
}
void OnTriggerExit2D(Collider2D collision)
{
if (collision.gameObject.tag == "Player")
{
Player.enabled = true;
Player_animator.SetBool("Pushing", false);
Debug.Log("EXIT");
}
}
void OnTriggerStay2D(Collider2D collision)
{
if (collision.gameObject.tag == "Player")
{
if (Move > .5f)
{
Player_animator.SetBool("Pushing", true);
Debug.Log("STAYING");
}
}
}
} ```
Comment
Your answer