So im developing this 3D based topdown game in Godot 3.3.4. I've wrote some code for the player movement but it causes the player to slowly slide while standing on ramps.
I kinda can imagine how to fix it but I think im over engineering a prety simple fix, so im asking the comunity. Is there a simple way to make the player stay on place while touching groud?
(Im aware of move_and_slide_with_snap() method but i couldn't make it work correctly either) (im also aware i forgot aplying delta)
Here's the code:
export var speed = 7.5 const GRAVITY = Vector3.DOWN * 100 var velocity = Vector3.ZERO func _physics_process(delta): velocity += GRAVITY * delta velocity = move_and_slide(velocity, Vector3.UP) var input_vector = Vector2.ZERO input_vector.x = Input.get_action_strength("ui_right") - Input.get_action_strength("ui_left") input_vector.y = Input.get_action_strength("ui_down") - Input.get_action_strength("ui_up") input_vector = input_vector.normalized() velocity.x = input_vector.x * speed velocity.z = input_vector.y * speed move_and_slide(velocity)
This is my first community ask so hi and thank u.
Solved
I got some gifs but apparently u need 10 rep and im new so...
Thank you Theraot, i've enabled the slope thing but than just worked sometimes. So I've made some changes and i think im okay with this:
extends KinematicBody
export var speed = 750
const GRAVITY = Vector3.DOWN * 10
var velocity = Vector3.ZERO
func _physics_process(delta):
velocity += GRAVITY * delta
velocity = move_and_slide_with_snap(velocity, Vector3.DOWN, Vector3.UP, true, 1, 0.80)
var input_vector = Vector2.ZERO
input_vector.x = Input.get_action_strength("ui_right") - Input.get_action_strength("ui_left")
input_vector.y = Input.get_action_strength("ui_down") - Input.get_action_strength("ui_up")
input_vector = input_vector.normalized()
velocity.x = input_vector.x * speed * delta
velocity.z = input_vector.y * speed * delta
move_and_slide_with_snap(velocity, Vector3.DOWN, Vector3.UP, true, 0, 0.785398)
Im shure that code is pretty much to work on but the movement is okey and it only slides a bit on big ramps so that can be a "fun" thing.
Im closing this but if somebody want to correct that code im okay with it. Have fun.


