using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ClusterBomb : MonoBehaviour
{
public float delay = 3f;
public float radius = 5f;
public float force = 700f;
public GameObject explosioneffect;
public GameObject OverlyBasicGrenade;
float countdown;
bool hasExploded = false;
// Start is called before the first frame update
void Start()
{
countdown = delay;
}
// Update is called once per frame
void Update()
{
countdown -= Time.deltaTime;
if (countdown <= 0f && !hasExploded)
{
explode();
hasExploded = true;
}
}
void explode()
{
Instantiate(explosioneffect, transform.position, transform.rotation);
Instantiate(OverlyBasicGrenade, new Vector3(transform.position.x, transform.position.y +0.5f, transform.position.z, +0.5f), transform.rotation);
Instantiate(OverlyBasicGrenade, new Vector3(transform.position.x + 0.5f, transform.position.y + 0.5f, transform.position.z), transform.rotation);
Instantiate(OverlyBasicGrenade, new Vector3(transform.position.x, transform.position.y - 0.5f, transform.position.z), transform.rotation);
Vector3 explosionPosition = OverlyBasicGrenade.transform.position;
Collider[ ] colliders = Physics.OverlapSphere(transform.position, radius);
foreach (Collider nearbyObject in colliders)
{
Rigidbody rb = nearbyObject.GetComponent();
if (rb != null)
{
rb.AddExplosionForce(force, transform.position, radius);
}
}
Destroy(gameObject);
}
}
It’s telling me the error is on line 37, but I’m assuming it’s on all three of the Instantiate OBG lines.
if the version i’m using is important, I believe it is 2019.4.28f1? I also don’t have any intellisense help downloaded so sorry if this is a very easy fix.
Firstly, use code tags goddamit! Secondly you get CS1729 when there is no available constructor for the parameters you passed. I took a quick look, and you are trying to give 4 parameters into the Vector3 constructor, which makes no sense. Use Vector3( x,y,z ) or Vector3( x,y ) or Vector3().
Unity forums just for some reason gets an endless number of low effort posts, and people get tired of it. Don’t take it personal, just next time use code tags when you post code and provide the full error message. The error code is the least useful part of the error message, since no one memorizes thousands of them. The text description of the error, and the line number it occurs, are the only important parts.
See here for some intellisense help, since it would have highlighted this error for you in the code if already set up correctly: https://discussions.unity.com/t/778503