- Home /
Assets/Scripts/PlayerController.cs(29,22): error CS1547: Keyword `void' cannot be used in this context
Getting a void context error and not sure why, apologies, quite new to C# coding and new to unity itself. Below is the code structure if anyone is happy to help. The code itself is being used to count how many times the player collects a specific item.
using UnityEngine;
using System.Collections;
public class PlayerController : MonoBehaviour {
public float speed;
private int count;
public GUIText countText;
void Start () {
count=0;
CountText();
}
void OnTriggerEnter(Collider other){
if(other.gameObject.tag=="item"){
other.gameObject.SetActive(false);
count = count + 1;
CountText();
}
if(other.gameObject.tag=="Hazard"){
other.gameObject.SetActive(false);
Vector3 jump = new Vector3(0.0f, 30, 0.0f);
rigidbody.AddForce (jump * speed * Time.deltaTime);
}
void CountText(){
CountText.text="Count: " + count.ToString();
}
void FixedUpdate () {
float moveHorizontal = Input.GetAxis("Horizontal");
float moveVertical = Input.GetAxis("Vertical");
Vector3 movement = new Vector3(moveHorizontal,0.0f,moveVertical);
GetComponent<Rigidbody>().AddForce(movement*speed*Time.deltaTime);
}
}
Comment
Oh my I feel like an absolute fool now haha, thank you so much Tanoshimi :)!
Your answer
Follow this Question
Related Questions
"The name 'Convert' does not exist in the current context" C# 2 Answers
Weird Error c# 1 Answer
getting loop errors, need help 1 Answer