so i used the rpg tutorial and also copied some from the said rpg example
here is my battle scene
when i choose the fight option, the healthbar wouldn’t drain, help would be appreciated
so i used the rpg tutorial and also copied some from the said rpg example
It could be a mix of conditions that runs each frame combined withe the asyncronous timer (wait action)
when you use “wait” all events/conditions in your game are still running. You should not consider it as it’s running inside its own event.
from the wiki
There are a few precautions to take when using a Wait action:
Avoid running it in an event where conditions are valid for more than one frame. If you use it without conditions, multiple Wait will be stored in memory, and the actions will all be launched later, which will slow down the game. Instead, prefer to use conditions like "At the beginning of the scene", a collision condition (with either a "Trigger Once" or an action to delete one of the object), etc...
First try to simplify things to check if the healt is really working.
Like if z key is pressed —> subtract 5 healtpoints.
TRIGGER ONCE
secondly i would try with sync timers instead of a wait action. bcs you have more control power in its own event.
Thaz what i would do
Just keep in mind that your variable turn true and false events are running each frame everytime with wait actions they may gonna end in a loop
I don’t see any actions to adjust the resource (health) bar. After damage is added, you need to update the bar.
Something like
(The mouse event is just there as an example)
Just make sure the maximum and initial values of the bar is set to the starting health value.
The wait actions can also cause problems. They build up if the condition that triggered them is still true. And once thier wait times have expired, they will begin to pickup with the actions and conditions after the wait. It becomes more of a delay than a wait. A timer is more structured and keeps the sequence of events in order.
Which is a good replacement for a wait action?
wel…it is not a good replacement…bcs i too find the wait action convenient…
but the problem is what we said above…
The other method is to get confident with timers (scene and object).
like eg
if z pressed -----> start scene timer “hit”
trigger once
if scene timer “hit” >3, trigger once -------> change vare Turn set to true, delete scene timer hit".
If you never used a timer i suggest to create a simple project to test them and get confident with.
There are a lot of options. Your current code is fairly small. You could add another Boolean varible like IsBusy with a default value of false. You can name your variable anyrhing that makes sense.
Turn is false
Collision
IsBisy is false
And then the first action would be
Set IsBusy to true
The last action would be
SetBusy to False
That would create an IsBusy state and prevent the player from applying multiple hits.
For the computers turn. I think you just need a trigger once.
Turn is true
Trigger once
As for a timer approach, you would still need some form of busy Boolean.
This is how I might do it. I’m not saying it’s the best way. The best way might be to add the IsBusy Boolean and use Wait. I’m just showing you one of the possible way.
so i tried to add the busy variable, but it would only get stuck on the busy affter the fight option
when i remade the first bits of the code, when i clicked preview, i could not do anything in this scene
Better wait Keith for an in-depth answer…
But i would check this first:
so i am able to do things in the scene, but the problem with trigger onces is that it only does the enemy turn and wait once and never again, and the healthbar is still not draining
Hello, i made a reply to you adressing new issues
Wel…i haven’t noticed more frome your SS so i dunno why isn’t working…someone may notice what i have not
You might need to show it to Keith, he might notice
Have you made any changes? If so, can you post a screenahot of the current events.
Your version is a bit more complex than my simple example.
This might need to be false not true.
Did changing that to false change anything?
What exactly is happening or not happening?
When does it happen?
so basically when i choose fight, i hit the enemy (healthbar still not draining), then busy and the enemy functions play out once and never again, and changing it to false changed nothing
I don’t see any actions to adjust the health bar. Are there any? When it stops working, check the debugger and see what the variables are. See if any of the variables are in the wrong state.
Are there any conditions for the health bars. Or are they subevents to something that has conditions?
If it’s not the player’s turn according to the boolean. I don’t know if the busy_please_wait should still be true.
Look at your conditions and see which events should be triggering according to the values of the variables. Either something isn’t the right value or the ues are being changed multiple times.
I can’t tell by the screenahots. I would suggest that you follow the path it takes based on the variables.
Figuire out why the busy_please_wait is still true and what’s preventing the player_turn from going back to true.
It can be tough. You have to follow the execution path.
so there are no conditions for health bars (i solved the variable thing myself)