Sorry for such a simple question lol

I have the movement working, but i dont know how to get the player to die, and know when to stomp on the enemy. I Think the stomping could work by checking the players y vel but i have to clue how to execute code as the player (Such as bouncing after the stomp). Can anyone help?

Godot 4.0.rc2

  • SuperMatCat24 Sorry if im dumb, but how do i make the bounce() method? i tried a signal to the player but it breaks when i go into a dif scene

    method = func method_name_here():

    So create the method function named bounce in your player script. Then call it from the area_entered method on the 'goomba' if body.name() is "player": ... something something to determine direction ... and if entered from top then call body.bounce()(assuming that's what you named the method in player) should work I think.

    That way it shouldn't be scene dependent either btw.

You could simply have an area attached to the 'goomba' and when it's area_entered signal is fired in the connected class you would make a check via if statement to see if the entered body is the player, if so then you make a comparison between the goombas global position and the players global position to figure out what direction the player entered from. If from above the 'goomba' then the goomba dies, else the player.

Cool! Would this also allow me to make the player bounce off it, or do i need seperate code in the player script?

The aforementioned signal connected class could call a method from the player, I see no reason why you couldn't have a bounce() method to call implemented in the player.

Sorry if im dumb, but how do i make the bounce() method? i tried a signal to the player but it breaks when i go into a dif scene

    Are you making a basic platformer? Here's a radical idea, Godot's actually quite an advanced engine, you wouldn't need to even change scenes unless you were doing something ridiculous. Most of the time scene transitions and loading up new levels was developers coming up with a way to get around the limitations of hardware among other things. Now though? You could simply fake a transition and have your character spawn at a different area of the scene you already have. Players wouldn't know the difference but if you wanted to make it look convincing you could do a simple fade in/fade out effect, this would let you keep the signals without breaking them, loading screens are something of a relic of the past these days unless you're dealing with a particularly massive game.

    SuperMatCat24 Sorry if im dumb, but how do i make the bounce() method? i tried a signal to the player but it breaks when i go into a dif scene

    method = func method_name_here():

    So create the method function named bounce in your player script. Then call it from the area_entered method on the 'goomba' if body.name() is "player": ... something something to determine direction ... and if entered from top then call body.bounce()(assuming that's what you named the method in player) should work I think.

    That way it shouldn't be scene dependent either btw.