- Home /
Issue regarding triggers?
using UnityEngine; using System.Collections;
public class manwalk : MonoBehaviour {
float walkSpeed = 90f;
float forwardSpeed = 0.5f;
bool didwalk =false;
Animator animator;
bool dead = false;
// Use this for initialization
void Start () {
animator = transform.GetComponentInChildren<Animator>();
if(animator == null){
Debug.LogError("Didn't find the animator");
}
}
//Do grphics here
void Update () {
if (Input.GetKeyDown(KeyCode.Space) || Input.GetMouseButtonDown(0)){
didwalk =true;
}
}
// do physics here
void FixedUpdate () {
if(dead)
return;
rigidbody2D.AddForce(Vector2.right * forwardSpeed);
if(didwalk ){
rigidbody2D.AddForce(Vector2.up * walkSpeed);
animator.SetTrigger("Dowalk");
didwalk =false;
}
}
void OnCollisionEnter2D(Collision2D collision){
animator.SetTrigger("Death");
dead = true;
}
}
I am updating my script thanks to @Graham Dunnett for pin pointing the mistake. thanks a lot sir.
Comment
Answer by Graham-Dunnett · Feb 10, 2015 at 12:21 PM
Typo on line 38. Enter not Entre.
hahahahahaha thank you so much sir i don't know how to thank you you are really great and i really really appreciate your fast and to the point reply @Graham Dunnett
Your answer

Follow this Question
Related Questions
Distribute terrain in zones 3 Answers
unityengine.animator does not contain a definition for parameters 0 Answers
Multiple Cars not working 1 Answer
OnTriggerEnter Not Working 1 Answer
How to get trigger input on an Xbox controller (Mac) 0 Answers