Question by
Ljrnet · Nov 09, 2015 at 04:02 AM ·
c#scripting problemtrigger
[SOLVED] Need help with my OnTriggerEnter code.
Hi guys. I'm using unity 5.2.2 and I'm having a problem with my code.
using UnityEngine;
using System.Collections;
public class Door1 : MonoBehaviour {
Animator animator;
bool doorOpen;
void Start()
{
doorOpen = false;
animator = GetComponent<Animator>();
}
void OnTriggerEnter(Collider col)
{
if (col.gameObject.tag == "Player") {
doorOpen = true;
DoorControl ("Open");
Debug.Log (123);
}
}
void DoorControl(string direction)
{
animator.SetTrigger(direction);
Debug.Log (321);
}
}
When the player hits the trigger it says this in the console.
Parameter type 'Open' does not match. UnityEngine.Animator:SetTrigger(String)
unity-forum-help-004.jpg
(436.9 kB)
Comment
Best Answer
Answer by Ljrnet · Nov 10, 2015 at 12:48 AM
I figured the problem was in my animation parameters, I had the "Open" parameter set as an int. but i had to set it as a trigger. Changing that fixed the problem.