Search Unity

Looking for ideas on how mechanics

Discussion in 'General Discussion' started by Tecknowolf01, Aug 17, 2015.

  1. Tecknowolf01

    Tecknowolf01

    Joined:
    Oct 31, 2012
    Posts:
    49
    My team and I are making a vehicular combat game, but I am having a hard time figuring out how to implement Hit Points.

    Each car will be a different class, like in Team Fortress 2, then there are different weapons and armor add ons. Is there a guide, reference, or something to help figure it out?
    Thanks for any help!
     
  2. JohnPet

    JohnPet

    Joined:
    Aug 19, 2012
    Posts:
    85
    What do you mean "how to implement Hit Points" exactly. Do you mean you need a way for the collisions to work or do you need a unique mechanic?
     
  3. Master-Frog

    Master-Frog

    Joined:
    Jun 22, 2015
    Posts:
    2,302
    Subtract hp from infinity.
     
    Jamster likes this.
  4. Tecknowolf01

    Tecknowolf01

    Joined:
    Oct 31, 2012
    Posts:
    49
    How do you figure out a vehicles total HP that works so weapons don't attack it all day. How to figure weapon damage on an object, compared to another weapon?
     
  5. JamesLeeNZ

    JamesLeeNZ

    Joined:
    Nov 15, 2011
    Posts:
    5,616
    See the learn section at the top. You need to go there. And learn.

    There are so many parts to that question... you really need to get a better understanding of Unity dev.
     
    Not_Sure likes this.
  6. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    It's unclear what you are asking for. If you want specific help on implementing a mechanic you have designed, go to scripting.

    If you need help designing mechanics, go to game design.
     
    TonyLi likes this.
  7. ShilohGames

    ShilohGames

    Joined:
    Mar 24, 2014
    Posts:
    3,021
    I would create a health class in C# and attach it to each game object that needed to have hit points. Write public methods in that class for actions like taking damage and adding health. Then have the weapon projectiles call those public functions on impact.

    For projectile impacts, I would suggest using raycasts to see if the projectile would hit a collider on the next frame. If it would, then call the target game object's health class method for taking damage. And then destroy the projectile, or return it to the projectile object pool as an inactive object.
     
  8. ostrich160

    ostrich160

    Joined:
    Feb 28, 2012
    Posts:
    679
    So you want a health script? Well this is incredibly basic stuff, that honestly you should really know/learn, but here goes
    This is in unity script btw

    Code (JavaScript):
    1. var Health : int = 10;
    2.  
    3. function Update(){
    4. if (you get hit with bullet type 1, either collisions or raycast)
    5. Health -= 1;
    6. }
    7.  
    8. if (you get hit with bullet type 2, either collisions or raycast)
    9. Health -= 3;
    10. }
    11.  
    12. if (you get hit with bullet type 3, either collisions or raycast)
    13. Health -= 8;
    14. }
    15.  
    16.  
    17. }
    And then you just want a boolean which will be set to false, that gets set to true if health is 0 or lower. Then, before adding in any functionality, such as player movement, shooting, you just want to say if(dead == false){
    before it
     
  9. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    Totally agree. The OP should step back and clarify what they want to accomplish first. A shop system to buy upgrades? A ruleset that determines how many hit points a car gets from various upgrades? A system that detects hits and subtracts hit points from car parts? A way to represent current hit point damage with mesh deformation?

    No sense us guessing at solutions when we don't know the problem yet.
     
    Kiwasi and ostrich160 like this.
  10. JohnPet

    JohnPet

    Joined:
    Aug 19, 2012
    Posts:
    85
    Well, I guess a vehicle's total HP is divided by the armor/objects the vehicle is made of.

    Creating a script, add a number of Transforms and attach the vehicle's armor pieces to those transforms. Afterwards, in the same script, create HP variabales for all pieces. The total HP of the vehicle is summing up all those HP variables (overallHealth = bumperHealth + exhaustHealth + chasisHealth + etc).

    Now, for the weapons specific damage, create a separate damage script with a damage variable for each weapon, and simply subtract that damage from your health, or from your armor pieces, depending on where the weapon projectile hit. Colliders play a big role in this. Good Luck.
     
  11. Tecknowolf01

    Tecknowolf01

    Joined:
    Oct 31, 2012
    Posts:
    49
    Much appreciated of all the information.

    I apologize for not being as clear as I should have been.

    What I am trying to figure out is, how do people figure out how much damage a weapon does, as a range of data for its minimum and maximum damage. Then figure out how much total Hit Points a player has, say a car.

    I am trying to make a vehicular combat game like World of Tanks, Armored Warfare, or War Thunder. They have a vehicle hitpoint system for their vehicle, multiple weapons that deal variable amounts of damage and armor penetration, and then component damage like engine, weapon, drive system, and so on.

    I am trying to also read and learn the board game Car Wars as it has a similar game play as I am trying to create.

    Some days, working 40+ hours, researching, going to school, and organizing a small game studio and playing other games to see how they work and feel tends to be a bit much.

    Thanks!
     
  12. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    Iteration! :)

    First you need to identify what you're iterating toward. Fast, easy kills with quick respawns? Or slowly wearing down your enemy in a cat-and-mouse game? Or something else?

    Then keep playing with numbers until it feels right for your desired gameplay. The fastest way to get there is by doubles and halves, not by tiny increments. Gun too powerful? Cut the damage value in half. Car too weak? Double the armor value. Bomb seem to unpredictable? Cut the min/max damage variance in half. Playtesters start to use one weapon exclusively? Cut that weapon's damage in half or double the others' damage.

    This is also a good technique when you don't know what you're iterating toward. As you vary the numbers, it will change how the game plays. You may find that playtesters enjoy one play style over the others.

    I'm in a similar boat with time, so I hear you. It may seem like it would take longer to get the game done by incorporating continuous playtesting from the beginning, but it gives you confidence that you're on track. When you don't have enough hours in the day, the worst feeling is hitting a dead end and having to backtrack a lot of work because it ended up not being fun.