Error CS1519
Trying to create a collision wall, where I can enter through one side, but can't go through another one I'm Getting Error CS1519, I can fix it by adding a " ; ", on the end of this line > GameObject.GetComponent But it creates a new error, I'm really new to this, so explaining why the error is here, and how should I type the script, would be blessful.
using UnityEngine; using System.Collections;
public class CollisionWall : MonoBehaviour {
GameObject.GetComponent<BoxCollider>
// Update is called once per frame
void update() {
// Makes the Wall a non colision object.
if (Input.GetKey (KeyCode.A)) {
BoxCollider2D.enabled = false;
Debug.Log("This is an Illusion");
}
else {
BoxCollider2D.enabled = true;
Debug.Log("This is a WALL");
}
} }
Answer by hexagonius · Feb 16, 2017 at 07:15 PM
The line
GameObject.GetComponent<BoxCollider>
is imcomplete (missing();
) ,in the wrong place (not within any method) and starts withGameObject
instead ofgameObject
or nothing. Better delete itit's uppercase
void Update()
BoxCollider2D
is the class you're trying to accessenabled
from. If you wanted to access that from aBoxCollider2D
component on the same GameObject, then itsGetComponent<BoxCollider2D>().enabled