What am I doing wrong?
Hi just to be fast
What am I doing wrong ?
Answer by Jawchewa · May 10, 2017 at 01:52 AM
You are missing spaces in your script when declaring variables. So change it from
public GameObjectblueBall, greeBall, orangeBall;
to
public GameObject blueBall, greeBall, orangeBall;
Same problem with your bool. Add a space beteen "bool" and "isGameOver"
I did it and it solved everything, but right after that I got this message :
error CS0103: The name `greenBall' does not exist in the current context
Still can't understand that context part :S
When writing my answer, I was trying to be consistent with the na$$anonymous$$g that you had in the image. In the original image, you had a typo where you misnamed what should be "greenBall" as "greeBall". So just add that extra "n" in your variable definition.
As for that error, basically, it means that the compiler can't find any variable in your code with the name that you are trying to use. When referencing a variable, make sure that you spell the variable with the exact same spelling and capitalization as when you created it. Also, just make sure that the variable has been properly created initially, so that you don't run into something like the issue that you had in your original problem.
I hate it when this happens :(. But thanks a lot man, it's working now
Answer by rehyan5103 · Oct 16, 2017 at 05:10 AM
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class PlayerController : MonoBehaviour
{ private Rigidbody rb;
public float speed;
private void Start()
{
rb = GetComponent<Rigidbody>();
}
private void FixedUpdate()
{
float moveHorizontal = Input.GetAxis("Horizontal");
float moveVertical = Input.GetAxis("Vertical");
Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical);
rb.AddForce(movement * speed)
}