'does anybody know how to make an animation happen once when a player with tag player walks into a trigger
Makes the animation trigger and destroys the trigger after being touched by the player
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
// You should make the name TheSecretWallScript
// This is the general format for classes in C#
public class Thesecretwallscript : MonoBehaviour
{
// needed to change this.
[SerializeField] private Animator anim;
// Start is called before the first frame update
private void OnTriggerEnter(Collider other)
{
// Disables trigger so it doesn't trigger again
other.enabled = false;
// Triggers animation, "AnimTrigger" should refer to the trigger you set
// in your animators settings
Animator anim = GetComponent<Animator>();
anim.SetTrigger("AnimTrigger");
}
}
Solution 1:[1]
You are destroying the trigger even before the animation trigger happens. Try doing the anim.getcomponent in the start method and animation.settrigger and in the next line other enabled =false.
Something like that
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Joel48 |
