First time posting here, sorry in advance for any mistakes. I’m trying to do a simple enemy “killing” mechanic, just like a goomba. A simple, “you jump on it, it dies”, and it’s working great, except for this one problem: Whenever i jump on the enemy, and hold the jump key all throughout the jump and jump on the enemy, the player just falls right through the enemy, ignoring all collision.
collision doesn’t make the player “physically collide” per say. collision what it does… it simply check if one hitbox overlaps another hitbox. Thats it.
if you want the player to jump again automatically, you must put events that make the character jumps (ex: apply a force).
in your event, you put simulate pressing jump key, (which will only trigger a jump depending on what you put in your jump events (where you use jump key in your code))
the issue is that normally, when we code our jump mechanics, we only make the character jump while he is grounded. (enemy is not a ground). while your player killed the enemy, the player is floating, therefore the character doesnt jump.
as i said, don’t simulate a key pressed. simply put your code that makes the character jumps directly (ex: apply a force)
if you used simulate key pressed to keep it as modular as possible. simply do my solution but with keeping your jump mechanics inside an external event, (that you would call here and at the jump key pressed)
You possibly..need to delete the enemy in the next frame ..so that you’re jumping off it …then the next frame it’s deleted…so set an object Boolean ‘delete’ to true …and above the collision event that sets it to true have …
Thanks for the reply! The code is actually working as intended in every other occasion. You jump on the enemy, it dies, and you jump out of it. The only instance that makes it not work is when you jump, and keep the jump key held for the entire duration of the jump and then land on the enemy. If the key is held the whole time, the enemy does die, but the player doesn’t jump.
Thanks for the reply! i tried that too, but it didn’t work. I even deleted the “delete object” condition, and the player normally keeped bouncing on the enemy, except for when the key is being held for the whole duration of the jump, in that case, the player just falls through the enemy completely.
Have you tried abort jump prior to allow jump again…I’m on my phone so can’t test any of this
The other way to try it is give the enemy platform behaviour…but only turn it on when jumping on it. So instead of collision test a point below the player is inside enemy then turn on enemy platform behaviour and then an event to test if player on a given platform..
I have tried the Abort Jump action, the only effect it had was briefly stoping the player before they fell. As for the platform behavior, when i tried it, the game just treated the enemy as a normal platform, completely ignoring the events.
He does get deleted, but the part of the code that’s supposed to make the player “bounce of him” are not working when the key is held. I didn’t add a event to deal with the jump key being pressed, i’m using the “remap for platformer” extension, and the white enemy has no behaviors, i haven’t added ai to it yet.
Then replace trigger once with player opacity = 255
In action change player opacity to 254 and delete enemy but remove other actions
Now make new event BELOW it (NOT sub event) and in that event check if opacity of player = 254
In action simulate jump key being pressed
Also i wonder shouldn’t it count as air jump?
Do you have extension for that or was it built in to platformerbehavior?
BTW i would either add force to player or tween its Y pos
It appears to be a characteristic of the platformer behaviour - I’m assuming a flag/setting is reset once the jump key is released to indicate a jump can happen again. And because the key is held down, that flag isn’t being reset and jump cannot be performed again.
Thanks! this actually did fix it. The problem now is that having the jump key be a “Key just pressed” event, is that the player’s jump has a set height know. Is there a workaround for that?