Recreating move_contact_solid() function from GameMaker Studio 2

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Afely

I’m trying to recreate a platformer controller from GMS2, but I’m stuck on converting the move_contact_solid() function. If you’re not familiar, it basically moves the object in a direction until it hits a solid object. Here’s the docs for it: Link
Would anyone know how to do this? Any help would be greatly appreciated. Thanks!

:bust_in_silhouette: Reply From: denxi

Using a KinematicBody2D, call either move_and_collide or move_and_slide.

You can read more about this process here - Using CharacterBody2D/3D — Godot Engine (stable) documentation in English

Thanks, but that’s not quite what I’m looking for. I need to be able to move the node by setting its position, and then have it snap to a surface when it’s colliding.

edit: Sorry, my mistake, I figured out a way to make it work. Thanks for your help!

Afely | 2020-11-14 07:30