I have a problem with the error CS0120 : An object reference is required to access non- static member , could someone help me with it?> Blockquote
using UnityEngine;
using System.Collections;
public class PlayerBehaviour : MonoBehaviour {
public Transform mesh;
public float forceFly;
private Animator animatorPlayer;
private float currentTimeToAnim;
private bool inAnim;
// Use this for initialization
void Start () {
animatorPlayer = mesh.GetComponent ();
}
// Update is called once per frame
void Update () {
if (Input.GetMouseButtonDown (0)) {
inAnim = true;
Rigidbody2D.AddForce (new Vector2 (0, 1) * forceFly);
}
if(inAnim){
currentTimeToAnim += Time.deltaTime;
if(currentTimeToAnim > 0.4f){
currentTimeToAnim = 0;
inAnim = false;
}
}
animatorPlayer.SetBool("callfly", inAnim);
}
}
↧