1
\$\begingroup\$

I get the error:

Invalid call. Nonexistent function 'get_action_strength' in base 'InputDefault'.

extends KinematicBody2D

export (int) var speed = 400
export (float) var rotation_speed = 10

var velocity = Vector2()
var rotation_dir = 0
var stance = 0

func ready():
    Input.action_set_deadzone("left", 0.25)
    Input.action_set_deadzone("right", 0.25)
    Input.action_set_deadzone("up", 0.25)
    Input.action_set_deadzone("down", 0.25)

static func angle_to_angle(from, to):
    return fposmod(to-from + PI, PI*2) - PI





func get_input():
    var left_joy_axis_h = Input.get_action_strength("right") - Input.get_action_strength("left")
    var left_joy_axis_v = Input.get_action_strength("up") - Input.get_action_strength("down")

    rotation_dir = 0
    velocity = Vector2()




    if(Input.is_action_just_pressed("stance")):
        if(stance == 0):
            stance = 1
        else:
            stance = 0
    if(stance == 0):
        velocity = Vector2()
        velocity += Vector2(speed, 0) * left_joy_axis_h
        velocity += Vector2(0, speed) * left_joy_axis_v
        if(angle_to_angle(rotation, velocity.angle()) > 0):
            rotation_dir = 1;
        elif(angle_to_angle(rotation, velocity.angle()) < 0):
            rotation_dir = -1;
        else:
            rotation_dir = 0
    elif(stance == 1):   
        rotation_dir = (Input.get_joy_axis(0,7) - Input.get_joy_axis(0,6))

        velocity = Vector2()
        velocity += Vector2(speed, 0).rotated(rotation + PI/2) * Input.get_joy_axis(0,0)
        velocity -= Vector2(speed, 0).rotated(rotation) * Input.get_joy_axis(0,1)




func _physics_process(delta):
    get_input()
    rotation += rotation_dir * rotation_speed * delta
    move_and_slide(velocity)
\$\endgroup\$
  • 4
    \$\begingroup\$ It looks like get_action_strength will be available in Godot 3.1 which hasn't been released yet. \$\endgroup\$ – skrx Jul 5 '18 at 17:00
  • 1
    \$\begingroup\$ Hey, you might want to un-delete your answer, and add that you could always get the master branch from the repository and build from the source :) \$\endgroup\$ – Alexandre Vaillancourt Jul 6 '18 at 3:07

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.