How do i make it so that my character can't die once they are in something?

so i am making a stealth game and I was stuck on something where you were to hide in a bush but not get attacked but once you’re out u can get attacked. Here’s the game: Flowlab Game Creator - Within The Shadows 2D

1 Like

Here:
You should use the enabled block that turns physics off for that object, and for extra precaution, make a switch that turns off when the player is in the bush. But only the code in the player is nessicary.

In player:

1 Like

Sometimes you want to detect collisions still by some things, so Enable is a very case specific “solution”.
A much better solution would just be a Switch that turns off while you are in the bush, meaning you take no damage while in it. So it’s partially what Flying_Fajita said, just don’t use enable if you don’t have it, it’s not a flexible way to create a system. So the switch isn’t an “extra precaution”, it’s the actual solution.

2 Likes

In this case though, this actually kept the player in the bush, so the enemy would just bonk into it and push him out. If you wanted to use the switch, you’d have to do some extra things and I wanted to keep it simple for this user.

If you wanted to do that, you would actually need to care about how

1; the “damage” is in the enemy, not the player
2; their using alerts, not damage
3; their using the janky run and jump bundle
4; their code for the bush is very janky.

This is why I decided to keep this out. I would have to edit a bunch of things, pretty much all the code they have already done.

1 Like

i am adding a health system a bit later on, which I already know how to do.

1 Like

how would u want me to implement the switch code, whenever I use the enabled code it just stops the player

1 Like

wdym, works fine for me…

k but i am just temporarily using the alert system just to so I know if the player has collided with the enemy

1 Like

also, i need to know how to use what u suggested about the switch

1 Like

Whatever causes the player to take damage, place a switch after that. If the player enters the bush, turn that switch off, if the exit the bush, turn it back on

2 Likes

arg does this work

{"data":{"behavior":{"v":"2","nodes":[{"inputCount":0,"outputCount":0,"name":"Bush","behaviorType":"logic.NodeGroup","x":-900,"y":-96,"group":"","id":"fcbd00ff3c123445","isMenuItem":false},{"inputCount":1,"outputCount":0,"name":"Message","behaviorType":"logic.components.Message","x":-270,"y":-64,"group":"fcbd00ff3c123445","id":"fba3dc18dd64cd4d","msg":"look","route":"SendToSelected","targetClassId":17194110},{"inputCount":1,"outputCount":1,"name":"Alpha","behaviorType":"logic.properties.Alpha","x":-450,"y":-96,"group":"fcbd00ff3c123445","id":"fbbfd897b3d74044"},{"inputCount":3,"outputCount":1,"name":"Number","behaviorType":"logic.logic.Value","x":-630,"y":96,"group":"fcbd00ff3c123445","id":"fbc2379a331b8442","startVal":100,"tag":"","roundMode":1},{"inputCount":1,"outputCount":1,"name":"Alpha","behaviorType":"logic.properties.Alpha","x":-450,"y":96,"group":"fcbd00ff3c123445","id":"fbc276b02cb1cc42"},{"inputCount":0,"outputCount":1,"name":"Collision","behaviorType":"logic.triggers.Collision","x":-900,"y":0,"group":"fcbd00ff3c123445","id":"fbc4127d89227648","targetClassId":17205426,"targetEntityId":0,"collisionFilter":15,"collideWithEntity":false,"delay":0},{"inputCount":0,"outputCount":2,"name":"Keyboard","behaviorType":"logic.triggers.Keyboard","x":-900,"y":96,"group":"fcbd00ff3c123445","id":"fc1228804f7d5f4a","keyCode":83,"repeats":false,"delay":0},{"inputCount":2,"outputCount":2,"name":"Enabled","behaviorType":"logic.properties.Enabled","x":-630,"y":0,"group":"fcbd00ff3c123445","id":"fcb182c85e2b704a"},{"inputCount":3,"outputCount":1,"name":"Number","behaviorType":"logic.logic.Value","x":-630,"y":-128,"group":"fcbd00ff3c123445","id":"fbc02170de71a743","startVal":0,"tag":"","roundMode":1},{"inputCount":0,"outputCount":1,"name":"Always","behaviorType":"logic.triggers.Always","x":-90,"y":-32,"group":"fcbaedc81f0f814b","id":"fcbb16d3365a3d40"},{"inputCount":2,"outputCount":3,"name":"Proximity","behaviorType":"logic.components.Prox2","x":90,"y":-64,"group":"fcbaedc81f0f814b","id":"fcbb22ff47cf454c","targetEntityId":0,"threshold":20,"targetClassId":17194110,"nearestOnly":false,"firstObject":true,"allObjects":false,"contains":false,"shape":0},{"inputCount":3,"outputCount":1,"name":"Switch","behaviorType":"logic.logic.Switch","x":360,"y":-64,"group":"fcbaedc81f0f814b","id":"fcbb52d06e10044c","_startVal":1,"dataType":2},{"inputCount":1,"outputCount":0,"name":"Bundle Output","behaviorType":"logic.NodeGroupOutput","x":540,"y":-64,"group":"fcbaedc81f0f814b","id":"fcbb8c72d8067b47","portId":"fcbaedc81f0f814bo0","tag":"In","dataType":2},{"inputCount":4,"outputCount":2,"name":"Position","behaviorType":"logic.properties.Position","x":900,"y":-224,"group":"fcbaedc81f0f814b","id":"fcbc59dafd18a640","pixelUnits":true,"resetVelocity":false},{"inputCount":3,"outputCount":1,"name":"Number","behaviorType":"logic.logic.Value","x":720,"y":-288,"group":"fcbaedc81f0f814b","id":"fcbca62dcc082b49","startVal":0,"roundMode":1},{"inputCount":3,"outputCount":1,"name":"Number","behaviorType":"logic.logic.Value","x":720,"y":-192,"group":"fcbaedc81f0f814b","id":"fcbca6e6ab108d4d","startVal":0,"roundMode":1},{"delay":0.1,"count":1,"version":2,"inputCount":3,"outputCount":1,"name":"Timer","behaviorType":"logic.triggers.Timer","x":540,"y":-192,"group":"fcbaedc81f0f814b","id":"fcbddaac5dac8342"},{"inputCount":0,"outputCount":1,"name":"Bush Prox.","behaviorType":"logic.NodeGroup","x":-900,"y":-128,"group":"fcbd00ff3c123445","id":"fcbaedc81f0f814b","isMenuItem":false}],"links":[{"input_id":"fba3dc18dd64cd4di0","output_id":"fbbfd897b3d74044o0"},{"input_id":"fbc276b02cb1cc42i0","output_id":"fbc2379a331b8442o0"},{"input_id":"fbc2379a331b8442i1","output_id":"fbc4127d89227648o0"},{"input_id":"fcb182c85e2b704ai0","output_id":"fc1228804f7d5f4ao0"},{"input_id":"fbc2379a331b8442i1","output_id":"fc1228804f7d5f4ao0"},{"input_id":"fbbfd897b3d74044i0","output_id":"fbc02170de71a743o0"},{"input_id":"fcbb22ff47cf454ci1","output_id":"fcbb16d3365a3d40o0"},{"input_id":"fcbca62dcc082b49i0","output_id":"fcbb22ff47cf454co0"},{"input_id":"fcbb52d06e10044ci2","output_id":"fcbb22ff47cf454co0"},{"input_id":"fcbca6e6ab108d4di0","output_id":"fcbb22ff47cf454co1"},{"input_id":"fcbb52d06e10044ci1","output_id":"fcbb22ff47cf454co2"},{"input_id":"fcbddaac5dac8342i0","output_id":"fcbb52d06e10044co0"},{"input_id":"fcbb52d06e10044ci0","output_id":"fcbb52d06e10044co0"},{"input_id":"fcbb8c72d8067b47i0","output_id":"fcbb52d06e10044co0"},{"input_id":"fcbc59dafd18a640i0","output_id":"fcbca62dcc082b49o0"},{"input_id":"fcbc59dafd18a640i1","output_id":"fcbca6e6ab108d4do0"},{"input_id":"fcbca62dcc082b49i1","output_id":"fcbddaac5dac8342o0"},{"input_id":"fcbca6e6ab108d4di1","output_id":"fcbddaac5dac8342o0"},{"input_id":"fbc02170de71a743i1","output_id":"fcbaedc81f0f814bo0"},{"input_id":"fcb182c85e2b704ai1","output_id":"fcbaedc81f0f814bo0"}]}}}

@mickbro_12

is it ok if u try showing me by screen shot plz its a bit hard to understand which behaviour I should use, sorry for being a bit of a pain here

1 Like

XD copy the code, then click anywhere (while editing the behaviours) then click “import”, this will create the code for you.

What the button will look like:


That bush bundle is what should be added

1 Like

oh my god thankyou so much bro this helps

2 Likes