Question by
DJWolfang25 · Oct 15, 2015 at 04:28 PM ·
c#ball
How do I fix script? error CS1525 Unexpected Symbol `ballObject' expecting `)', `,',`;',`[', or `=' .
I'm trying to make a pong game to get into game design and this is the video tutorial I am trying to follow. I keep getting this error on line 13 (The ballObject right after Ball ball). I'm using Unity 4. Can someone please help?
using UnityEngine; using System.Collections;
public class Enemy : MonoBehaviour {
public float speed = 8;
Vector3 targetPos;
GameObject ballObj;
void Start()
{
Ball ball
ballObject = GameObject.FindGameObjectWithTag ("Ball");
}
void Update ()
{
targetPos = Vector3.Lerp (gameObject.transform.position,ballObject,transform.position,Time.deltaTime * speed);
gameObject.transform.position = new Vector3 (20, targetPos.y, 0);
}
}
Comment
You remove one of the redundant valiable names in your declaration
Ball ball ballObject = ...
Just like you have correctly done in
float speed = 8;
// not
float speed speedNumber = 8;
Then you will get another error because you are trying to find a GameObject and put that into a variable that's of type Ball. So you have to use GetComponent() to get the Ball script from your GameObject.
Ball ball = GameObject.FindGameObjectWithTag ("Ball").GetComponent<Ball>();