0 votes

SO, I have a vehicle that uses custom movement for KinematicBody. The issue is, ONLY when I am moving or turning at angles that are not normal to X, Z, the game struggles to keep frames due to likely physicsprocess(delta).

Here is the movement so far:

export var steering_limit = 15  # front wheel max turning angle (deg)
var acceleration = Vector3.ZERO  # current acceleration
var velocity = Vector3.ZERO  # current velocity
export var engine_power = 10
export var braking = -6.0

func get_input(delta):
if is_on_floor():
    if Input.get_action_strength("turnLeft"):
    elif Input.get_action_strength("turnRight"):
    acceleration = Vector3.ZERO
    if Input.is_action_pressed("accel"):
        acceleration = -transform.basis.z * engine_power
    if Input.is_action_pressed("reverse"):
        acceleration = -transform.basis.z * braking

Here is the moveandslide physics process:

func _physics_process(delta):
if active == false:
    if is_on_floor():
        velocity = Vector3.ZERO
    elif not is_on_floor():
        acceleration.y = gravity
        velocity += acceleration * delta
        velocity = move_and_slide_with_snap(velocity, -transform.basis.y, Vector3.UP, true)
elif active == true:
    hidden_plyr.global_transform.origin = get_parent().get_node("Terrain").transform.origin + Vector3(0,2000,0)
    if is_on_floor():
    acceleration.y = gravity
    velocity += acceleration * delta
    velocity = move_and_slide_with_snap(velocity, -transform.basis.y, Vector3.UP, true)

NOTE: I know I can use move and slide without snap but Id prefer it so I can calculate for normals on hills and such and interpolate that with snapping, unless I dont have to. IDK yet, still trying things out, all possibilities atm.

But any ideas? Thank you if you can help :) Hope all is well!

Godot version 3.2.3 Stable
in Engine by (16 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 Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.