- Home /
Question by
87manproductions · Mar 31, 2015 at 06:09 PM ·
errorcs0120
error 0120 Help
I keep having trouble with a C# script. I keep fixing errors, and unity finds other errors. One of which I can't figure out how to fix. `using UnityEngine; using System.Collections;
using UnityEngine;
using System.Collections;
public class PresstoAttack : MonoBehaviour {
// Update is called once per frame
void Update () {
if (Input.GetKey(KeyCode.RightArrow)) {
Animator.SetBool("attacking", true);
}
else {
Animator.SetBool("attacking", false);
}
}
}
Comment
Answer by DoTA_KAMIKADzE · Mar 31, 2015 at 06:51 PM
First of all when you post question about error then post it (I mean post whole error not just code).
From what I can see you use Animator class but should use Animator instance instead, something like this:
private Animator anim;
private void Awake()
{
anim = GetComponent<Animator>();
}
void Update()
{
if (Input.GetKey(KeyCode.RightArrow))
{
anim.SetBool("attacking", true);
}
else
{
anim.SetBool("attacking", false);
}
}
Your answer
Follow this Question
Related Questions
Error Code CS0118 or CS0120 1 Answer
Error CS0120 0 Answers
Help with more code 2 Answers
BlockBreaker Tutorial: CS0120 Error. 0 Answers
error CS0120: An object reference is required to access non-static member 1 Answer