Stuck in coding rules
Hey all, I know this is kind of a long story, but I would appreciate any help cause I'm stuck for days in this problem now and tried everything I could think of..
I have problems in 2 different scenes.
The problems in both scenes are alike.
When player in the main scene clicks on the 'train' button, it changes the scene to the 'training grounds', where an enemy actor spawns and randomly switches position, where you can hit him. After you got his life bar to 0, or if you die yourself, the scene gets switched automatically back to he main scene, where the player can start over again and hit the 'train' button again if desired. If the enemy mob is hit he will interpolate to red for 1 second and interpolate back to normal colors after.
The main problem is i want this enemy actor every time the player hits the train button on the main scene, to be spawned at the exact same position in the 'training grounds scene', in the middle of the screen. The enemy actor is black then and after a countdown of 3 seconds he will interpolate to normal colors and be fightable. After these 3 seconds the enemy actor will randomly spawn positions.
The way I set things up now, and I had this problem earlier on another scene also, everything works fine at the first time the player pushes the 'train' button.
After that tho, if the player is back to the main scene again after a 'training session' on the 'training grounds', and he hits 'train' again, things go tricky.
The enemy mob spawns, but on some way or another, the mob's random position rule, which i set to only go off after 3 seconds, goes off right away. The enemy actor sometimes doesn't appear in black too (interpolated rule), but in normal colors and sometimes in red-ish, probably because the last time the player did the 'training session' he hitted the enemy actor and this actor somehow reminds this and go red again.
My rules:
Main scene:
TRAIN BUTTON: If touched, change attribute 'enemymob' to '1'.
set 'lifemeter_enemy' to '100'
set 'lifemeter_hero' to '100'
change scene to 'training grounds'
Actors:
ENEMY ACTOR: if attribute 'enemymobspawn' is '1', spawn actor in scene (on perfected positions of course)
after 3 seconds, every 2 seconds, set position 'enemymob' to 'random(1,3)'
if attribute 'lifemeter_enemy' = '0', set attribute 'enemymobspawn' to '0'
if attribute 'enemymobspawn' is '0', destroy actor
DAGGER BUTTON: if enemymob is at position random1, and touch is pressed, set life.enemyactor to '-5'
SWORD BUTTON: if enemymob is at position random2, and touch is pressed, set life.enemyactor to '-5'
CROSSBOW BUTTON: if enemymob is at position random3, and touch is pressed, set life.enemyactor to '-5'
TRAINING SCENE:
In the training scene the meters get to 100, so that works
In the training scene the first time player enters, the enemy actor spawns up perfect on position and in size,
gets destroyed perfectly after lifemeter_hero gets to 0 etc. Only thing that doesnt work is the second, third or whatever extra time you get into this scene by pressing the train button on the main scene. The enemymob spawns, but doesn't await it's 3 seconds before randomly reposition every 2 seconds and does it right away and isnt black.
ps. i didnt include all the detailed rules like interpolating, cause this all works and it's extra info which might confuse you.
Please anyone help, really stuck here.
Best regards,
I have problems in 2 different scenes.
The problems in both scenes are alike.
When player in the main scene clicks on the 'train' button, it changes the scene to the 'training grounds', where an enemy actor spawns and randomly switches position, where you can hit him. After you got his life bar to 0, or if you die yourself, the scene gets switched automatically back to he main scene, where the player can start over again and hit the 'train' button again if desired. If the enemy mob is hit he will interpolate to red for 1 second and interpolate back to normal colors after.
The main problem is i want this enemy actor every time the player hits the train button on the main scene, to be spawned at the exact same position in the 'training grounds scene', in the middle of the screen. The enemy actor is black then and after a countdown of 3 seconds he will interpolate to normal colors and be fightable. After these 3 seconds the enemy actor will randomly spawn positions.
The way I set things up now, and I had this problem earlier on another scene also, everything works fine at the first time the player pushes the 'train' button.
After that tho, if the player is back to the main scene again after a 'training session' on the 'training grounds', and he hits 'train' again, things go tricky.
The enemy mob spawns, but on some way or another, the mob's random position rule, which i set to only go off after 3 seconds, goes off right away. The enemy actor sometimes doesn't appear in black too (interpolated rule), but in normal colors and sometimes in red-ish, probably because the last time the player did the 'training session' he hitted the enemy actor and this actor somehow reminds this and go red again.
My rules:
Main scene:
TRAIN BUTTON: If touched, change attribute 'enemymob' to '1'.
set 'lifemeter_enemy' to '100'
set 'lifemeter_hero' to '100'
change scene to 'training grounds'
Actors:
ENEMY ACTOR: if attribute 'enemymobspawn' is '1', spawn actor in scene (on perfected positions of course)
after 3 seconds, every 2 seconds, set position 'enemymob' to 'random(1,3)'
if attribute 'lifemeter_enemy' = '0', set attribute 'enemymobspawn' to '0'
if attribute 'enemymobspawn' is '0', destroy actor
DAGGER BUTTON: if enemymob is at position random1, and touch is pressed, set life.enemyactor to '-5'
SWORD BUTTON: if enemymob is at position random2, and touch is pressed, set life.enemyactor to '-5'
CROSSBOW BUTTON: if enemymob is at position random3, and touch is pressed, set life.enemyactor to '-5'
TRAINING SCENE:
In the training scene the meters get to 100, so that works
In the training scene the first time player enters, the enemy actor spawns up perfect on position and in size,
gets destroyed perfectly after lifemeter_hero gets to 0 etc. Only thing that doesnt work is the second, third or whatever extra time you get into this scene by pressing the train button on the main scene. The enemymob spawns, but doesn't await it's 3 seconds before randomly reposition every 2 seconds and does it right away and isnt black.
ps. i didnt include all the detailed rules like interpolating, cause this all works and it's extra info which might confuse you.
Please anyone help, really stuck here.
Best regards,
Goodboi Gamestudios | Monster Jumper now on the App Store
Comments
Put that on your training button before it switches scenes.
If those are all scene attributes that can't be accessed from your training button then put all the resets needed when the enemy is destroyed or the player is, before it kicks them back to the other scene.
Could I just make a boolean reset scene
and on the train button in the main scene make if touch change attribute scenereset to 1
and on the training grounds scene make if scenereset = 1, reset scene?
Goodboi Gamestudios | Monster Jumper now on the App Store
Goodboi Gamestudios | Monster Jumper now on the App Store
From your post, you were basically saying that it was remembering things from the old battles, so that means you've got attributes still set from the old battles that needs setting back to normal/default with change attributes. And the best place to do this is either on the training button, or on the rule that sends the player back a scene when they've destroyed the enemy or they themselves were killed.
Also he is not black and interpoled to normal colors after 3 colors, also not after reset, the second time player enters the trainings grounds.
I tried really everything, on numerous ways like i said, but i really dont understand how to do it.
Even the reset scene, which also should reset the enemy, will not do.
Even then the enemy will spawn right, on the right position, but the interpole is incorrect then (turns to normal colors right away and sometimes even still has the red color of the hit of a previous training game, which dissapears in a second then.
Is it helpful if i put all codes here? (thats very much tho)
Goodboi Gamestudios | Monster Jumper now on the App Store
Goodboi Gamestudios | Monster Jumper now on the App Store
Goodboi Gamestudios | Monster Jumper now on the App Store
Main scene:
'Train'-button:
'Training grounds'-scene:
'Enemy mob' actor:
(There is a lot of detailed rules in this which doesnt have to do with the my bug, but it might have, you never know, the mob got a random spawn (1,3) rule, and all 3 rules are written on these screens too. So that's why so many rules.)
'Training grounds'-scene:
'background' actor:
Hope you guys can help me out.
Goodboi Gamestudios | Monster Jumper now on the App Store
Are you definitely destroying the actor before you leave the scene and re-spawning a new one each time you go to the scene? Are there any possibilities where this might not be happening?
After a fight in the training grounds, i switch all attributes off before going back to the main scene. The enemy mob gets destroyed before switching back to the main scene.
In the train button, if pressed, I switch all attributes on, before going tot the training scene, and the enemy mob gets spawned in a certain direction.
I really have the feeling this is a bug of GS, I won't say this quick, but i have the same troubles in an other scene, where a sort of duckhunt-ish ' hunting ground' is.
The ducks fly from one position to another, when touched there moving direction changes to down untill they are off screen, then they are destroyed. But after 10 seconds, when the hunting time is over and player gets kicked back to mainscreen and player clicks 'hunt' again, the last killed ducks are still in screen falling down, while they should be destroyed. It's actually the same problem as in the training grounds, where the enemy mob is still doing actions of the previous time player has been there, while it is definately destroyed and respawned.
Goodboi Gamestudios | Monster Jumper now on the App Store
Being in a new file without all of the noise from the rest of your game in it might even help find a better way to do it
Do the same with the enemy training ground. Create a really basic version with a couple of attributes.
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
@FryingBaconStudios those are some very good tips. I tought I did all the rules before the change scene rule, but I'm gonna doublecheck and the touch is released tip is perfect! I checked out your videos before but never saw a code order video of you but will recheck. Thanks!
Goodboi Gamestudios | Monster Jumper now on the App Store
My training grounds are working perfect now ^.^, so the rest should do too.
Goodboi Gamestudios | Monster Jumper now on the App Store
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
That rule IS working by the way, altho it's behind the change scene rule.
Goodboi Gamestudios | Monster Jumper now on the App Store