+2 votes

I'm new to Godot and I'm having this issue.

I want to put an unhandled input ability to my mouse click but I can't because I have to put it in physics process delta. I want all my inputs to be unhandled. How can I have both? Code:

extends KinematicBody2D

const UP = Vector2(0,-1)
var motion = Vector2()
var is_dead = false
var grav = 18
var timer = null
var is_dashing = false
func _physics_process(delta):
    if is_dead == false:
        motion.y += grav

        motion.x = 300

        if Input.is_action_pressed("ui_right"):
            dash()

        if is_on_floor():
            if Input.is_action_just_pressed("ui_select"):
                motion.y = -400
                if Pixel.has_node("pass_through"):
                    Pixel.set_collision_mask_bit(1,false)
                else:
                    motion.y = -400
        move_and_slide(motion,UP)

        if get_slide_count():
            for i in range(get_slide_count()):
                if "Fire" in get_slide_collision(i).collider.name:
                    dead()
        if get_slide_count():
            for i in range(get_slide_count()):
                if "Flame" in get_slide_collision(i).collider.name:
                    dead()


func dead():
    is_dead = true
    $DeathSound.play()
    motion = Vector2(0,0)
    $Particles2D.emitting = true
    $Sprite.play("dead")
    $CollisionShape2D.disabled = true
    $deadtimer.start()

func _on_Luck_Bits_body_entered(body):
    global.luckscore +=1
    print(global.luckscore)

func _on_Spring_body_entered(body):
    motion.y = -500

func _on_deadtimer_timeout():
    get_tree().reload_current_scene()


func _on_ghost_timer_timeout():
    if Input.is_action_pressed("ui_right"):
        var this_ghost = preload("res://ghost.tscn").instance();
        get_parent().add_child(this_ghost)
        this_ghost.position = position;  
        this_ghost.texture = $Sprite.frames.get_frame($Sprite.animation , $Sprite.frame);



func dash():
    motion.x += 300


func _on_dashtimer_timeout():
    motion.x = 300


func _on_DashButton_pressed():
    dash()
in Engine by (28 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.