How to move a KinematicBody2D relative to it's position?

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

I’m using the move_and_slide() function for my player character. The only issue with this is that it only takes global co-ordinates - if I add to the y value, the character falls down relative to the entire world when I want him to fall towards his own “down”. How is this possible?

Are you talking about when the KinematicBody2D is rotated?

TheJokingJack | 2020-11-22 19:42

:bust_in_silhouette: Reply From: Millard

when you use the move_and_slide() function, it takes 2 arguments. The movement vector, and the up direction. If I am correct, you need to change the up direction if you want the character to fall differently. hope it helps =)

:bust_in_silhouette: Reply From: James122333

So if you want the character to fall down to it’s local co-ordinates use something like this:

if Input.is_action_pressed("ui_right"):
	velocity += transform.basis.x