- Home /
Question by
Dimitris4 · Apr 26, 2019 at 09:04 PM ·
scripting problemerrormonobehaviour
I can't add my script to a boss
public class FirstBossBhv : MonoBehaviour
{
public float speed;
public GameObject projectile;
private bool movingRight = true;
private bool movingLeft = false;
public Rigidbody2D rb2d;
void Update()
{
if(movingRight == true)
{
rb2d.velocity = transform.right * speed;
}else if(movingLeft == true)
{
rb2d.velocity = transform.right * -speed;
}
}
private void OnCollisionEnter2D(Collision2D collision)
{
if (collision.gameObject.CompareTag("2Walls"))
{
if(movingRight == true && movingLeft == false)
{
movingRight = false;
movingLeft = true;
}else if (movingRight == false && movingLeft == true)
{
movingRight = true;
movingLeft = false;
}
}
}
}
When I try to attach it to my boss, this error pops out, any help?
στιγμιοτυπο-οθονης-11.png
(42.4 kB)
Comment
Best Answer
Answer by KevRev · Apr 27, 2019 at 12:17 AM
Your bosspawn.cs file has an error stopping the compiler. You need to fix that. The error indicates that you are trying to instantiate without telling it what to instantiate. Line number and file name are in the error message.