Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

C# beginner problem- "Type 'Shooting' already defines a member called 'Shoot' with the same paramet"

Discussion in 'Scripting' started by RidarTV, Sep 27, 2020.

  1. RidarTV

    RidarTV

    Joined:
    Sep 27, 2020
    Posts:
    3
    I tried some 2D TopDown Shooting but everytime I save the script i get the error. The script is for creating a simple bullet.
    "Assets\Skripte\Shooting.cs(21,14): error CS0111: Type 'Shooting' already defines a member called 'Shoot' with the same parameter types"
    here is the code:

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;

    public class Shooting : MonoBehaviour
    {
    public Transform firepoint;
    public GameObject bulletPrefab;
    public float bulletForce = 20f;
    // Update is called once per frame
    void Update()
    {
    if (Input.GetButtonDown("Fire1"))
    {
    Shoot();
    }
    }
    void Shoot()
    {
    GameObject = Instantiate(bulletPrefab, firepoint.position, firepoint.rotation);
    Rigidbody2D rb = bullet.GetComponent<Rigidbody2D>();
    rb.AddForce(firepoint.up * bulletForce, ForceMode2D.Impulse);
    }

    }
     
    Last edited: Sep 27, 2020
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,762
    RidarTV likes this.
  3. RidarTV

    RidarTV

    Joined:
    Sep 27, 2020
    Posts:
    3

    OOPS, but thanks alot and sorry for wasting your time...