Search Unity

need help

Discussion in 'Getting Started' started by volcanicfire33, Jan 28, 2020.

  1. volcanicfire33

    volcanicfire33

    Joined:
    Jan 28, 2020
    Posts:
    9
    im trying to make my bullets disappear when they reach the cursor but im getting an error,
    i wrote this:
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class pewpew : MonoBehaviour
    6. {
    7.     private Vector2 target;
    8.     public float speed;
    9.     // Start is called before the first frame update
    10.     void Start()
    11.     {
    12.         target = Camera.main.ScreenToWorldPoint(Input.mousePosition);
    13.     }
    14.  
    15.     // Update is called once per frame
    16.     void Update()
    17.     {
    18.         transform.position = Vector2.MoveTowards(transform.position, target, speed * Time.deltaTime);
    19.         if(transform.position == target){
    20.  
    21.         }
    22.     }
    23. }
     
  2. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,780
    What error you get?
    Use Debug.Log, to track issues.
     
    Joe-Censored likes this.