In my game I have a simple trip wire which is activated when my player enters the trigger area. As to test my tripwire because I'm only in Alpha, I wanted it to spawn my basic enemy AI prefab but it comes with this error that I don't know how to fix.
Error CS0201: Only assignment, call, increment, decrement, and new object expressions can be used as a statement.
Here is my script:
using UnityEngine;
using System.Collections;
public class Tripwire : MonoBehaviour
{
bool Trap1;
bool Trap2;
public Transform enemy1;
// Use this for initialization
void Start ()
{
}
// Update is called once per frame
void Update ()
{
}
void OnTriggerEnter(Collider collided)
{
if(collided.GetComponent() != null )
{
Debug.Log ("WireTripped");
if(Trap1 == true)
{
Instantiate(enemy1, new Vector3(0, 0, 0), Quaternion.identity) as Transform;
}
}
}
}
↧