0 votes

Hello everyone! How are you all doing?

This happens only when the characters is on a vertical moving platform. For horizontal movements everything is fine. I'm using a KinematicBody being moved by a moveandslidewithsnap function. All the margins are already set to 0.001. The platform is being moved by an AnimationPlayer set to Physics.

Thanks!

A GIF showcasing the issue:
https://imgur.com/8k3NjQQ

Here's the player script:

extends KinematicBody

export var gravity = 3000

export var move_speed = 750

#jump
export var fall_multiplier = 1 
export var low_jump_multiplier = 10
export var jump_force = 1300
export var max_fall_speed = 3000

var y_velo = 0

var snap_normal = Vector3.DOWN setget set_snap_normal

func movement(delta):
    var move_vec = Vector3()
    if Input.is_action_pressed("move_left"):
        move_vec.x -= 1
    if Input.is_action_pressed("move_right"):
        move_vec.x += 1
    move_vec = move_vec.normalized()
    move_vec *= move_speed
    move_vec.y = y_velo
    move_and_slide_with_snap(move_vec * delta, snap_normal, Vector3.UP)

    var grounded = is_on_floor()
    y_velo -= gravity * delta

    if grounded:
        if Input.is_action_pressed("jump"):
            set_snap_normal(Vector3(0,0,0))
            y_velo = jump_force
        if y_velo <= 0:
            set_snap_normal(Vector3.DOWN)
            y_velo = 0
    if y_velo > 0 and Input.is_action_just_released("jump"):
        y_velo -= 30 * (low_jump_multiplier)
    elif y_velo < 0:
        y_velo -= 7 * (fall_multiplier)

func set_snap_normal(new_snap_normal):
    snap_normal = new_snap_normal

func _physics_process(delta):
    movement(delta)
asked Feb 19 in Engine by yiron (12 points)

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.