Point System for my Game

Godot Version

4

Question

Hello,
I am trying to make a point system for my game. How its gonna work is 10 hits on a player from the opposing team gives the player’s team a point. But I also want it so if they hit there teammates it subtracts 1 point. Can someone help me?

This is how I would structure that.

Create a separate script and class (autoload might be better if you have multiple levels and need to keep information between them).

Call it something like Game, or maingame or running_game or something like that.

Use that script to control everything about the running game.

Have variables in that class that keeps a score, and have functions that add and remove scores as required. Or you could set up and event (signal system)

Drive your UI off that information as well.

Each ‘team’ would be the same class and scene, define which is ‘red’ & ‘blue’ if you like or someway of telling which is which. Each player would sit under those teams as separate scenes in their own right, and you would just have two copies of them in your main scene.

When any team hits happen let the ‘main game’ object know (either by directly calling public functions or creating signals (Player on the team would send out the signals, the ‘main game’ object would subscribe and listen to them).

The main game object would then take information and run the logic you have described.

Update your UI accordingly.

Drink some beer.

huh
can you maybe give an example