Hi, I’ve got a GameObject called Foliage with a collider in front of it. The collider is tagged OneFo. When the player collides with the tagged collider, I’d like some animation on the foliage to be triggered. The animation is called OneFOL.
This bit seems wrong. I’ve tried all kinds of variations of code I’ve used before to trigger animations that worked but I can’t find the problem.
gameObject.GetComponent<Animation>("OneFOL");
gameObject.PlayAnimation("OneFOL");
Any help would be most appreciated.
using UnityEngine;
using System.Collections;
public class FoliageScript : MonoBehaviour {
GameObject Foliage;
// Use this for initialization
void Start () {
Foliage = GameObject.Find("Foliage");
}
// Update is called once per frame
public void OnTriggerEnter (Collider other) {
if (other.transform.tag == "OneFo")
{
gameObject.GetComponent<Animation>("OneFOL");
gameObject.PlayAnimation("OneFOL");
}
}
}