0 votes

i want leaning to be toggled but cant find anything that can help and cant figure it out myself

onready var head = self

export var default_lean : Vector3
export var right_lean : Vector3
export var left_lean : Vector3
var lean = false
export var lean_acceleration = 5
export var lean_accel = 1
onready var player = owner
var can_lean = true

func _process(delta):
    if Input.is_action_just_pressed("leanright") and not player.is_running:
    elif Input.is_action_just_pressed("leanleft") and not player.is_running:

func lean_right(delta):
    lean = true
    head.transform.origin = lerp(transform.origin, right_lean, 1)
    head.rotation.z = lerp(head.rotation.z, deg2rad(-10), 1)

func lean_left(delta):
    head.transform.origin = lerp(transform.origin, left_lean, 1)
    head.rotation.z = lerp(head.rotation.z, deg2rad(10), 1)
    lean = true

func lean_default(delta):
    lean = false
    head.transform.origin = lerp(transform.origin, default_lean, 1)
    head.rotation.z = lerp(head.rotation.z, deg2rad(0), lean_acceleration * delta)
Godot version 3.4
in Engine by (18 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.
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 webmaster@godotengine.org with your username.