When different targets are destroyed, they contribute amounts to the total score:
Large Targets: Add 22 points to the score when destroyed.
Medium Targets: Add 55 points to the score when destroyed.
Small Targets: Add 130 points to the score when destroyed.
I have set up the scoring system using an Enum type to the wildcard of the select node to decide the value for each target type. When a target is destroyed, its corresponding value is added to the total score. After the first round, the total score should accumulate to 880 points.
I just need help with adding the score depending on which target is destroyed and calculating the total score after the first round.
Values like score should be kept track of in the GameState! Then, when one of the targets is destroyed, you add its value to GameState’s “Score” value, using the point amount you set.
To use the Enum to determine the point amount, use “Switch On Enum” paired with an integer variable “Point Worth” on the construction script. So using the switch on enum you’ll set it to 22, 55, or 130.
To set these individually per target, set the Enum value to be Public and Instance Editable.
Now, when you drag them into the level, you go to the details panel of that target and there should be a way to change the Enum value for just that target. This will also switch the point value.
The best practice when using Gameplay Ability System is to create gameplay tags for each target type: small, med, large. There is a naming convention that organize tags per hierarchy, for instance:
Enemy.Target.Type.Small
Enemy.Target.Type.Med
Enemy.Target.Type.Large
Inside the game state blueprint associated with the scoring, create a logic to identify the gameplay tag of the scoring target, such as:
get actor or instigator-> has matching gameplay tag? → branch or select node
Depending how you coded your game, just create a score inside each target class and send to the game state via interface.
If you’re changing its static mesh, have one for Large, Medium, and Small, then when it is hit Set Visibility of your current active one to false, along with setting its collision profile (just that mesh) to NoCollision. At the same time, you’d Set Visibility to TRUE and the collision profile to whatever you need it to be other than No Collision for the NEW one.
So basically:
Start Enum on LARGE. On TakeDamage:
Get LMesh → Set Visibility: False && Set Collision Profile: NoCollision && Set Enum to MEDIUM
Get MMesh → Set Visibility: True && Set Collision Profile: WorldDynamic
Then the same thing for Medium to Small.
Then on small, destroy actor after all other code has been executed (such as score addition.)
Is your game multiplayer or single player? Are those targets AI enemies (“bots”) or players?
Are you using Lyra starter game or a custom project?
Typically, the easiest setup is done with the score being sent by the killed target (if on server) on “death event” straight to the scoring BP (Game State for MP or Game Mode for single Player) via interface message or event dispatcher. With this setup, you don’t need an ENUM. Your scoring BP will receive the exact value coming from the defeated target. If you have teams, you want to retrieve both score and team ID from the defeated target.
What exactly are you talking about? Do you mean you want a hud system set up? If your going for a hud system then you need to store the variable somewhere and then access it from the hud, such as a save state data. You can access it from your hud and then plug it into your changing variable in there. Did you need some sort of system for that?