0
Answered

Calling on Local Variable values has no effect

itsthehawke 2 months ago in Game Creator updated by Marti (Lead Developer) 2 months ago 1

Hey there,

so I created a health stat variable on my characters and I want to work with this variable further by adding a 'hurt state' if the health falls below a certain value and then ultimately "kill" the character when the health is on 0.

So far I have been able to change this var by colliding the enemy with my bullets, but nothing changes when my values are reached.

In my case, I use a local variable enemy_health, that has a default value of 100.

I have set a condition that checks if the variable value is equal or less than 25, then the character should become "hurt".

Same goes for checking if the health is equal or less than 0, then the character should turn into a ragdoll.

None of these actions ever start when reaching my designated values. Am I missing something?

Unity version:
2018.4.9f1
Game Creator version:
1.0.1

Answer

Answer
Answered

Seems like you are missing a Trigger. Actions are list of instructions that are sequentially executed. Conditions, allow to execute different Actions based on Conditions.

Both of these systems require a Trigger to be executed. A Condition alone don't listen for scene events. You'll probably want a Trigger set to "On Variable Change". This trigger will be executed every time a given Local Variable changes its value. You can then execute the Conditions you already made and change the State of the Player for the one called Hurt, or kill it if the variable value is below zero.

Hope this helps!

GOOD, I'M SATISFIED

Now that's the thing I'm missing here. Still pretty new to this.

Thank you very much for a swift and precise reply!

Satisfaction mark by itsthehawke 2 months ago
Answer
Answered

Seems like you are missing a Trigger. Actions are list of instructions that are sequentially executed. Conditions, allow to execute different Actions based on Conditions.

Both of these systems require a Trigger to be executed. A Condition alone don't listen for scene events. You'll probably want a Trigger set to "On Variable Change". This trigger will be executed every time a given Local Variable changes its value. You can then execute the Conditions you already made and change the State of the Player for the one called Hurt, or kill it if the variable value is below zero.

Hope this helps!