All Questions

Community

D
Yok-Him Devn

Top of pyramid

Hi Nathan,

So I made a little pyramid with the tile map, and when I walk over it, the player sprite exhibits the jump behaviour again. I tried tweaking the numbers in the following code without much success:

_velocity, snap, FLOOR_NORMAL, true, 3 if is_on_floor() or is_on_wall() else 1, PI/3.0

Also I can't stand on the tip of the pyramid, and when I force myself to the player sprite just got stuck on top of it as if skewered from the bottom and wouldn't move no matter how many times I press the arrow keys.

  • Nathan Lovato replied

    You're getting to more complex cases. You'll see that all the time when coding games: code that works in one case may not work in others, and the more cases you want to handle, or the more general you want your code to be, the more complex it gets.

    In this case, here are the parts that can help with the slope movement itself:

    • The snap vector might not be long enough, depending on the slope's angle, making the character not snap but jump a bit.
    • If your slope is steep, the max slope angle might not be enough, although PI/3.0 is already approximately 66 degrees.

    The movement on slope should be fine. The bit about the tip of the pyramid, I'm not sure. If you'd like, you can upload your project as a zip archive somewhere (could be some cloud provider or file sharing service) and I'll look at the source code directly.

  • D
    Yok-Him Devn replied

    Hello Nathan,

    Thanks for the suggestion, that's very generous of you. I've uploaded the project folder as a zip archive on Dropbox (think I'll get around to GitHub one day...): https://www.dropbox.com/sh/tfambiknagk88ko/AACIIvIJwRxvJ85sBd0RuJLsa?dl=0

    Also regarding the pause frame question on the lesson Designing the level's last challenge, I've played around with the code and got the following to work:

    func _on_body_entered(body: Node) -> void:
    	teleport()
    	get_tree().paused = true 
    

    but being transitioned this way, I found that the player couldn't interact with other elements of the second scene (enemy, coin, bumper). I wonder what role get_tree().paused play in this?

    I then tried to fiddle with the code in the second scene and found out that the first scene's code changed as well. Is there a way to change only the code of a specific scene?