I’m fairly sure this will be a simple one, but why would I be getting the error: The member `GameController.bunnyJump’ cannot be used as method or delegate in the following code?
using UnityEngine;
using System.Collections;
public class GameController : MonoBehaviour {
//variables for ground
public int groundcount;
public int groundlocation;
private Vector2 groundposition;
public GameObject groundObject;
private Quaternion groundRotation;
public GameObject rockObstacle;
public GameObject trunkObstacle;
public GameObject treeObstacle;
private Vector2 obstacleposition;
private int obstaclelocation;
private int obstacleRandom;
private int obstacleTypeRandom;
public int bunnyPower;
private float timeCurrent;
private float timeAtButtonDown;
private float timeAtButtonUp;
private float timeButtonHeld;
public bool bunnyJump;
// Use this for initialization
void Start () {
bunnyJump (false);
//Set initial ground and set first obstacles
groundcount = 0;
groundposition = new Vector2 (groundlocation, -4);
obstacleRandom = 0;
while (groundcount <20)
{
//Create the ground
GroundCountAdd();
}
//create initial obstacles
AddObstacle ();
}
// Update is called once per frame
void Update () {
timeCurrent = Time.fixedTime;
//add ground if needed
if (groundcount <= 20)
{
GroundCountAdd ();
}
//if obstacles need to be added, add them
if (obstaclelocation < groundlocation)
{
AddObstacle();
}
//power up jump
if (Input.GetMouseButton (0)) {
if (bunnyJump (false)) {
bunnyJump (true);
Debug.Log ("Pressed left click.");
}
} else {
if (bunnyJump(true))
{
bunnyJump(false);
Debug.Log ("Released left click.");
}
}
}
public void GroundCountAdd()
{
Instantiate(groundObject, groundposition, groundRotation);
groundcount = groundcount +1;
groundlocation = groundlocation +2;
groundposition = new Vector2 (groundlocation, -4);
}
public void GroundCountSubtract()
{
groundcount = groundcount - 1;
}
public void AddObstacle()
{
obstacleTypeRandom = (int)Random.Range (1, 101);
if (obstacleTypeRandom <= 30) {
//Add a rock
obstacleposition = new Vector2 (obstaclelocation, -2);
Instantiate (rockObstacle, obstacleposition, groundRotation);
obstacleRandom = (int)Random.Range (2, 5);
obstaclelocation = obstaclelocation + (obstacleRandom * 2);
} else if (obstacleTypeRandom >= 31 && obstacleTypeRandom <= 60) {
//Add a tree trunk
obstacleposition = new Vector2 (obstaclelocation, -2.1f);
Instantiate (trunkObstacle, obstacleposition, groundRotation);
obstacleRandom = (int)Random.Range (3, 6);
obstaclelocation = obstaclelocation + (obstacleRandom * 2);
} else if (obstacleTypeRandom >= 61) {
//Add a tree
obstacleposition = new Vector2 (obstaclelocation, 1);
Instantiate (treeObstacle, obstacleposition, groundRotation);
obstacleRandom = (int)Random.Range (3, 6);
obstaclelocation = obstaclelocation + (obstacleRandom * 2);
}
}
/*
public void OnMouseDown(){
timeAtButtonDown = timeCurrent;
Debug.Log ("Time button pressed" + timeAtButtonDown);
}
public void OnMouseUp (){
timeAtButtonUp = timeCurrent;
Debug.Log ("Time button released" + timeAtButtonUp);
timeButtonHeld = (timeAtButtonUp - timeAtButtonDown);
Debug.Log ("TimeButtonHeld = " + timeButtonHeld);
} */
}