Search Unity

im trying to delete my bullet on collision help

Discussion in 'Scripting' started by mlgdude123456, Apr 17, 2021.

  1. mlgdude123456

    mlgdude123456

    Joined:
    Apr 12, 2021
    Posts:
    2
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;

    public class ProjectileTut : MonoBehaviour
    {
    private bool collided;
    void onCollisionEnter(Collision co)
    {
    if (co.gameObject.tag != "Bullet" && co.gameObject.tag != "Player" && !collided)
    {
    collided = true;
    Destroy(gameObject);
    }
    }
    }

    this what i have please help im new btw im using 2020.3.3 unity version and i followed a tutorial
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,735
    Back up and do the tutorial again because obviously you missed something critical. We all know collision works and if that tutorial doesn't help you, go find another... there are THOUSANDS.

    Screen Shot 2021-04-17 at 7.30.39 PM.png

    ALSO, if you post a code snippet, ALWAYS USE CODE TAGS:

    How to use code tags: https://forum.unity.com/threads/using-code-tags-properly.143875/

    How to report your problem productively in the Unity3D forums:

    http://plbm.com/?p=220

    How to understand compiler and other errors and even fix them yourself:

    https://forum.unity.com/threads/ass...3-syntax-error-expected.1039702/#post-6730855

    Also, consider this: