Looking for ideas on how mechanics

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!

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?

Subtract hp from infinity.

1 Like

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?

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.

1 Like

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.

1 Like

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.

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

var Health : int = 10;

function Update(){
if (you get hit with bullet type 1, either collisions or raycast)
Health -= 1;
}

if (you get hit with bullet type 2, either collisions or raycast)
Health -= 3;
}

if (you get hit with bullet type 3, either collisions or raycast)
Health -= 8;
}


}

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

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.

2 Likes

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.

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!

Iteration! :slight_smile:

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.