Hi! I am making a Horror game >:D
I want an animation to play when the Player hits the collider. Actually, the object with the trigger is a child of the object WITH the animation (See the image) this doesn’t matter, right? Anyway…
When the player collide with my trigger, i want a animation to play. I am using an animator, but i don’t know what to do. My script is in C# and it only play the animation when a certain key is pressed, not in collision. So, what do i need to do/change? Here’s my current script:
using UnityEngine;
using System.Collections;
public class Scarytest : MonoBehaviour
{
public KeyCode MyKey;
public string MyTrigger;
void Update()
{
if (Input.GetKey(MyKey))
{
GetComponent<Animator>().SetTrigger(MyTrigger);
}
}
}