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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

+Point When Bullet hit targets

Discussion in 'Scripting' started by A-Tunga, Aug 14, 2014.

  1. A-Tunga

    A-Tunga

    Joined:
    Jul 13, 2014
    Posts:
    13
    Hello,I am new on unity.I have question I have a gun it's firing ball's.And I want when ball hit target add point in gui text.Can you help me ? I don't where i gonna look... Thanks..
     
  2. jehovah0121

    jehovah0121

    Joined:
    Sep 28, 2011
    Posts:
    17
    a) Add a ball collider to the bullet prefab.
    b) Add proper colliders to the target game object. Try not to use complex mesh colliders but instead use combinations of primitive colliders for better performance.
    c) Check the 'is trigger' option on the target's colliders.
    d) On your target's script, implement a method 'void OnTriggerEnter(collider c)'. Check if the param c corresponds to a bullet (you can use GameObject tag to category your GameObjects in the scene). If yes, destroy the bullet, and send message to your GUI script to add points.
     
  3. A-Tunga

    A-Tunga

    Joined:
    Jul 13, 2014
    Posts:
    13
    Thank you so much,you give me an idea ontrigger enter so i made point system. :)