+1 vote
I see conflict with boths functions Keys on same script. Cant control my Character 3D have conflict look script

extends Spatial

var anim_player = null
var anim = ""
var anim_new = ""

var coordinate = 0
var upperarm_angle = Vector3()
var lowerarm_angle = Vector3()
var skel
var bone = "upperarm_r"
func _ready():
    skel = get_node("first_model/Skeleton")
    var bone = "upperarm_r"
    var coordinate = 0

    # variavel aponta para o nó principal da animação
    anim_player = get_node("AnimationPlayer")
    # get_node("Spatial_Player/AnimationPlayer").set_speed(0.2)

func set_bone_rot(bone, ang):
    var b = skel.find_bone(bone)
    var rest = skel.get_bone_rest(b)

    var newpose = rest.rotated(Vector3(1.0, 0.0, 0.0), ang.x)
 #   var newpose = newpose.rotated(Vector3(0.0, 1.0, 0.0), ang.y)
 #   var newpose = newpose.rotated(Vector3(0.0, 0.0, 1.0), ang.z)
    skel.set_bone_pose(b, newpose)

func _fixed_process(dt):
    if Input.is_action_pressed("select_x"):
        coordinate = 0
    elif Input.is_action_pressed("select_y"):
        coordinate = 1
    elif Input.is_action_pressed("select_z"):
        coordinate = 2
    elif Input.is_action_pressed("select_upperarm"):
        bone = "upperarm_r"

    elif Input.is_action_pressed("increment"):
        if bone == "upperarm_r": # tecla =
           if (upperarm_angle[coordinate] < 0.12):
              upperarm_angle[coordinate] += 0.1
    elif Input.is_action_pressed("decrement"):
        if bone == "upperarm_r":  # tecla -   
          if (upperarm_angle[coordinate] > -1.6):
              upperarm_angle[coordinate] -= 0.1
    set_bone_rot("upperarm_r", upperarm_angle)

    if (anim != anim_new):
        anim_new = anim
    if (Input.is_key_pressed(KEY_CONTROL)):

    if (Input.is_action_just_released("ui_select") == true):
        anim = "Pulando"

func _input(event):
     if (event.type==InputEvent.KEY and event.scancode == KEY_UP and event.pressed):
        anim = "Correndo"
     elif (event.type==InputEvent.KEY and event.scancode == KEY_DOWN and event.pressed):
          anim = "default"
     elif (event.type==InputEvent.KEY and event.scancode == KEY_LEFT and event.pressed):
        anim = "Andando"
   #  elif (event.type==InputEvent.KEY and event.scancode == KEY_SPACE):
   #     anim = "Pulando"
   #     anim_player.set_speed(1)
        anim = "Parado_Arma_Aniamando"

    please help me
in Engine by (101 points)
edited by

Please format your code properly. Just select it all and click on the { } button to format it as code. It is impossible to read it like this.

Please any idea for solve that?

fixedprocess(dt) not working fine with _input(event) in same script

What is the problem that you're having? That looks like valid code, though maybe it doesn't do what you're expecting it to.

Input.isactionpressed just checks whether or not that action is pressed right now. By putting it in fixedprocess, you're essentially looking for held-down keys.

The pattern I like to use for _input(event) is as follows:

func _input(event):
    if (event.type == InputEvent.KEY or event.type == InputEvent.JOYSTICK_BUTTON) and event.is_pressed() and not event.is_echo():
        if event.is_action("whatever"):
            # Do Whatever

The if condition identifies any keys (or joystick buttons) that were just pressed for the first time. Within that, I check for specific actions. Finally, and this is important, if I handle those actions, I call gettree().setinputashandled(). If you don't do this, then other things can pick up the same action, which is sometimes undesirable.

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.