I have a problem with the tutorial game roll-a-ball. When trying to make the script for the you win text, I get errors in the compiler about unexpected symbols like ; and }. Please help me.
using UnityEngine;
using System.Collections;
public class PlayerController : MonoBehaviour{
public float speed;
private int count;
public GUIText countText;
public GUIText winText;
void Start ()
{
count = 0;
SetCountText ();
winText = **;
}
void FixedUpdate()
{
float MoveHorizontal = Input.GetAxis ("Horizontal");
float MoveVertical = Input.GetAxis ("Vertical");
Vector3 movement = new Vector3(MoveHorizontal, 0.0f, MoveVertical);
rigidbody.AddForce (movement * speed * Time.deltaTime);
}
void OnTriggerEnter(Collider other)
{
if(other.gameObject.tag == "PickUp")
{
other.gameObject.SetActive(false);
count = count + 1;
SetCountText();
if(count >= 11)
{
winText.text = "You Win!";
}
}
}
void SetCountText()
{
countText.text = "Count: " + count.ToString ();
}
}
shouldnt this:
winText = **;
be this:
winText.text = "";
This post might help you:
http://forum.unity3d.com/threads/143875-Using-code-tags-properly
i did that (thanks btw) but it still says error on line 13 unrecognized symbol ;
Well I just tried it and there are no errors:
using UnityEngine;
using System.Collections;
public class PlayerController : MonoBehaviour{
public float speed;
private int count;
public GUIText countText;
public GUIText winText;
void Start ()
{
count = 0;
SetCountText ();
winText.text = "";
}
void FixedUpdate()
{
float MoveHorizontal = Input.GetAxis ("Horizontal");
float MoveVertical = Input.GetAxis ("Vertical");
Vector3 movement = new Vector3(MoveHorizontal, 0.0f, MoveVertical);
rigidbody.AddForce (movement * speed * Time.deltaTime);
}
void OnTriggerEnter(Collider other)
{
if(other.gameObject.tag == "PickUp")
{
other.gameObject.SetActive(false);
count = count + 1;
SetCountText();
if(count >= 11)
{
winText.text = "You Win!";
}
}
}
void SetCountText()
{
countText.text = "Count: " + count.ToString ();
}
}
Thanks soft, I just realized my error. Instead of ** on line 13, I should have “”. You may not have meant to help me, but thanks soft.
I did mean to help that’s why I answered you.
Glad you got it working anyway.