how do i trigger state machine ?
hi i would like to trigger a state animator. i have set up a bool as in the "animate anything" tutorial. but i would like to only have to click on the object. here's the state machine
i have set up a box collider on the object with this script.
using UnityEngine;
using System.Collections;
public class button_activator : MonoBehaviour {
private Animator animator;
void Awake () {
animator = GetComponent <Animator>;
}
void OnMouseDown (Collider other){
Animator.SetBool (pressed, true);
}
void OnMouseUp (Collider other){
Animator.SetBool (pressed, false);
}
}
but all my attempts get the thing not working thanks
Answer by OctoMan · Nov 09, 2015 at 03:07 PM
void OnMouseDown{
animator.SetBool (pressed, true);
}
void OnMouseUp {
animator.SetBool (pressed, false);
}
thanks @Octo$$anonymous$$an i have now this and it still doesn't work.
public class button_activator : $$anonymous$$onoBehaviour {
private Animator jollyroger;
void Awake () {
jollyroger = GetComponent <Animator>;
}
void On$$anonymous$$ouseDown (){
jollyroger.SetBool ("pressed", true);
}
void On$$anonymous$$ouseUp (){
jollyroger.SetBool ("pressed", false);
}
}
You're welcome, you just missed some brackets. But you noticed that already.
Answer by griiot · Nov 09, 2015 at 04:30 PM
thanks all. here's the corrected working script
using UnityEngine;
using System.Collections;
public class button_activator : MonoBehaviour {
private Animator jollyroger;
void Awake () {
jollyroger = GetComponent <Animator>();
}
void OnMouseDown() {
jollyroger.SetBool ("pressed", true);
}
void OnMouseUp() {
jollyroger.SetBool ("pressed", false);
}
}
Your answer
Follow this Question
Related Questions
change animation to make character face a waypoint. 0 Answers
Animation which uses trigger is played twice before going back to the previous state. 0 Answers
my counter wont change from 0 help 1 Answer
Need help with bone animation and trigger code. 0 Answers
Trigger not working on Enemy Prefab 3 Answers