Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

Hey, thank you ! I'm definitely not proud with the physics, but I spent a full day trying to do something better without success ... As a Godot user, you might know what I am doing wrong ? I use KinematicBody2D for the character and the platforms. The player moves with move_and_slide_with_snap in the _physics_process, while the islands have their position and rotation modified by AnimationPlayers synced to the physics process. I could increase the floor_max_angle in the move and slide of the character to stop constantly slide, but then it does weird things with the jump, and you can't jump in a tilted corner (which is even more annoying). A lot of times, it felt like Godot wasn't meant for this kind of experimental game.

(1 edit)

So, the move and slide function has this signature:

move_and_slide_with_snap ( Vector2 linear_velocity, Vector2 snap, Vector2 up_direction=Vector2( 0, 0 ), bool stop_on_slope=false, int max_slides=4, float floor_max_angle=0.785398, bool infinite_inertia=true )

What you basically need to do is set the “stop_on_slope” to be equal true, the max angle is in radians and the default value is 45º. if it still messes up with the jump, I’d say you are better off making your own “is_on_floor” function using maybe another area2d and/or raycast2d (if you do use raycast2d remember that they are not enabled by default) to generate it, then you can tweak them to have the desired result (if you only want to enable jump if the floor is rotated less than some deegree). The area can detect if there is ground below the player and the raycast can detect the angle of the ground (the normal vector of the collision)

(1 edit) (+1)

Thank you so much ! Here is my move and slide function right now :

velocity = move_and_slide_with_snap(velocity, snap_vector, Vector2.UP, false, 4, PI/2 * 0.7, true)

I had tried to with stop on slop true, but it's even more glitchy and the character never slides, which feels very weird on steep slopes. It would be nice to be able to control how slippy the terrain is.

The problem with the jump isn't actually that you can't jump, but it seems that you're jumping in two different directions at the same time when you are in a corner, which kinda cancels it. Now I am thinking about it, it might be due to my jump function, that's not working properly if there are multiple floors :

velocity += get_floor_normal() * jump_speed

Thanks again for the great explanations ! I'll try these ideas and others you gave me.