mirror of
https://github.com/jcreek/CosmicClash.git
synced 2026-07-14 11:33:47 +00:00
fix(*): Ensure moving backwards doesn't change y vector
This commit is contained in:
@@ -9,6 +9,7 @@ func get_input_vector() -> Vector3:
|
|||||||
var camera_transform = camera.global_transform
|
var camera_transform = camera.global_transform
|
||||||
var forward_direction = -camera_transform.basis.z
|
var forward_direction = -camera_transform.basis.z
|
||||||
var right_direction = camera_transform.basis.x
|
var right_direction = camera_transform.basis.x
|
||||||
|
var y_movement = input_vector.y
|
||||||
|
|
||||||
if Input.is_action_pressed("move_forward"):
|
if Input.is_action_pressed("move_forward"):
|
||||||
input_vector += forward_direction
|
input_vector += forward_direction
|
||||||
@@ -18,6 +19,13 @@ func get_input_vector() -> Vector3:
|
|||||||
input_vector -= right_direction
|
input_vector -= right_direction
|
||||||
if Input.is_action_pressed("move_right"):
|
if Input.is_action_pressed("move_right"):
|
||||||
input_vector += right_direction
|
input_vector += right_direction
|
||||||
|
|
||||||
|
# Zero out the Y component to restrict movement to the XZ plane
|
||||||
|
input_vector.y = 0
|
||||||
|
|
||||||
|
# Add back the preserved Y movement
|
||||||
|
input_vector.y = y_movement
|
||||||
|
|
||||||
if Input.is_action_pressed("move_up"):
|
if Input.is_action_pressed("move_up"):
|
||||||
input_vector.y += 1
|
input_vector.y += 1
|
||||||
if Input.is_action_pressed("move_down"):
|
if Input.is_action_pressed("move_down"):
|
||||||
|
|||||||
Reference in New Issue
Block a user