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

Shooting Object

Discussion in 'Scripting' started by CursedSword, Apr 26, 2016.

  1. CursedSword

    CursedSword

    Joined:
    Apr 26, 2016
    Posts:
    4
    Hallo guys,

    I want some object example ( weapon) shoot at enemy and if it kill 3 enemies the object will get extra life and if the object get shoot the life will decrease.

    for example the object shoot 3 enemies it get 1 extra life and shoot other 3 then the life will be 2 , and if someone shoot the object the life will be 1 and if it reach 0 it will be destroyed

    how can i make script for that ?

    i wait for your answers , thank you ;)
     
  2. Rob21894

    Rob21894

    Joined:
    Nov 21, 2013
    Posts:
    309
    Is the object carried by the player? is it a static turret?

    Need more information other than it shoots...

    Does it shoot towards mouse position?

    Towards the player?

    Towards Enemy?
     
  3. CursedSword

    CursedSword

    Joined:
    Apr 26, 2016
    Posts:
    4
    The object is the player
    Yes, it shoot towards the mouse position and , lets say for example the object is cube(player) and it shoot small spheres towards another cube(Enemy player) if it touch the other cube it will desroyed but it need 2 more kills to get extra life and in case it get extra life and someone shoot it the life will instantly decrease

    thx for your answer
     
  4. LeftyRighty

    LeftyRighty

    Joined:
    Nov 2, 2012
    Posts:
    5,148
    http://unity3d.com/learn/tutorials/projects/space-shooter/creating-shots?playlist=17147

    http://unity3d.com/learn/tutorials/projects/survival-shooter/player-health?playlist=17144
    in particular the relationship between TakeDamage() and Attack()


    for the lives approach you can see an example of discrete "lives" handling in this live training (pun unintentional :) )
    http://unity3d.com/learn/tutorials/modules/beginner/live-training-archive/creating-a-breakout-game
     
    CursedSword likes this.
  5. CursedSword

    CursedSword

    Joined:
    Apr 26, 2016
    Posts:
    4
    Thx bro for the information i'll check it
     
  6. CursedSword

    CursedSword

    Joined:
    Apr 26, 2016
    Posts:
    4
    Anyone have more information ?
     
  7. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    You really need to break this down into smaller tasks.
    • Move a projectile toward a target
    • Detect collisions
    • Count collisions
    • Increment a value on another script
    These tasks are pretty straight forward and can be googled.