Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Having trouble removing Error CS1729

Discussion in 'Getting Started' started by nathanbovia45, Jul 23, 2021.

  1. nathanbovia45

    nathanbovia45

    Joined:
    Jul 21, 2021
    Posts:
    10
    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<Rigidbody>();
    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.
     
  2. Epsilon_Delta

    Epsilon_Delta

    Joined:
    Mar 14, 2018
    Posts:
    258
  3. tyruji

    tyruji

    Joined:
    Jan 15, 2019
    Posts:
    1
    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().
     
  4. nathanbovia45

    nathanbovia45

    Joined:
    Jul 21, 2021
    Posts:
    10
    well sorry, I'm very new so I didn't know, there's no need to be vulgar and rude.
     
  5. nathanbovia45

    nathanbovia45

    Joined:
    Jul 21, 2021
    Posts:
    10
    I might just uninstall if i keep having to meet people like you while looking for help.
     
  6. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    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 code tags if you're having trouble:
    https://forum.unity.com/threads/using-code-tags-properly.143875/

    See here for some intellisense help, since it would have highlighted this error for you in the code if already set up correctly:
    https://forum.unity.com/threads/intellisense-not-working-with-visual-studio-fix.836599/

    Good luck, and have fun!
     
    nathanbovia45 likes this.
  7. nathanbovia45

    nathanbovia45

    Joined:
    Jul 21, 2021
    Posts:
    10
    thank you!
     
    Joe-Censored likes this.