correct issue on strafe action
This commit is contained in:
parent
de250310af
commit
09c4476938
1 changed files with 18 additions and 14 deletions
|
@ -71,21 +71,24 @@ func _physics_process(delta):
|
||||||
# Get the input direction and handle the movement/deceleration.
|
# Get the input direction and handle the movement/deceleration.
|
||||||
if Input.is_action_pressed("ui_strafe"):
|
if Input.is_action_pressed("ui_strafe"):
|
||||||
input_dir = Input.get_vector("ui_right", "ui_left", "ui_down", "ui_up")
|
input_dir = Input.get_vector("ui_right", "ui_left", "ui_down", "ui_up")
|
||||||
else: # if not Input.is_action_pressed( "ui_strafe" ):
|
else:
|
||||||
var y = 0
|
var y = 0
|
||||||
if Input.is_action_pressed("ui_right") and not Input.is_action_pressed("ui_strafe_right"):
|
if Input.is_action_pressed("ui_strafe_right") or Input.is_action_pressed("ui_strafe_left"):
|
||||||
y -= 1
|
input_dir = Input.get_vector("ui_strafe_right", "ui_strafe_left", "ui_down", "ui_up")
|
||||||
if Input.is_action_pressed("ui_left") and not Input.is_action_pressed("ui_strafe_left"):
|
else:
|
||||||
y += 1
|
if Input.is_action_pressed("ui_right"):
|
||||||
if y != 0:
|
y -= 1
|
||||||
var dt = y * delta * speed_rotate_1sec
|
if Input.is_action_pressed("ui_left"):
|
||||||
camera_rotate_y += dt
|
y += 1
|
||||||
if camera_rotate_y > PI:
|
if y != 0:
|
||||||
camera_rotate_y -= TWO_PI
|
var dt = y * delta * speed_rotate_1sec
|
||||||
elif camera_rotate_y <= -PI:
|
camera_rotate_y += dt
|
||||||
camera_rotate_y += TWO_PI
|
if camera_rotate_y > PI:
|
||||||
$camera_root/horizontal_root.rotate_y( dt )
|
camera_rotate_y -= TWO_PI
|
||||||
input_dir = Input.get_vector("ui_strafe_right", "ui_strafe_left", "ui_down", "ui_up")
|
elif camera_rotate_y <= -PI:
|
||||||
|
camera_rotate_y += TWO_PI
|
||||||
|
$camera_root/horizontal_root.rotate_y( dt )
|
||||||
|
input_dir = Input.get_vector("nothing", "nothing", "ui_down", "ui_up")
|
||||||
|
|
||||||
var direction = (transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
|
var direction = (transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
|
||||||
if direction:
|
if direction:
|
||||||
|
@ -97,6 +100,7 @@ func _physics_process(delta):
|
||||||
|
|
||||||
move_and_slide()
|
move_and_slide()
|
||||||
|
|
||||||
|
|
||||||
func _process( delta ):
|
func _process( delta ):
|
||||||
if debug:
|
if debug:
|
||||||
print(reconciliate_rotate_camer_player, ", ", camera_rotate_y,", ", player_rotate_y)
|
print(reconciliate_rotate_camer_player, ", ", camera_rotate_y,", ", player_rotate_y)
|
||||||
|
|
Loading…
Reference in a new issue