Freecam Mode
This commit is contained in:
parent
e3d9b04a64
commit
0fa362aed4
2 changed files with 28 additions and 4 deletions
|
@ -101,6 +101,16 @@ jump={
|
|||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":32,"key_label":0,"unicode":32,"location":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
freecam={
|
||||
"deadzone": 0.5,
|
||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":true,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":70,"key_label":0,"unicode":102,"location":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
descend={
|
||||
"deadzone": 0.5,
|
||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194325,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
|
||||
[rendering]
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ const SPEED: float = 5.0
|
|||
const JUMP_VELOCITY: float = 4.5
|
||||
|
||||
var activated: bool = false
|
||||
var freecam: bool = false
|
||||
|
||||
@onready
|
||||
var camera: Camera3D = $Camera3D
|
||||
|
@ -22,11 +23,24 @@ func _ready() -> void:
|
|||
|
||||
func _physics_process(delta: float) -> void:
|
||||
if activated:
|
||||
if not is_on_floor():
|
||||
velocity += get_gravity() * delta
|
||||
if !freecam:
|
||||
if not is_on_floor():
|
||||
velocity += get_gravity() * delta
|
||||
|
||||
if Input.is_action_just_pressed("jump") and is_on_floor():
|
||||
velocity.y = JUMP_VELOCITY
|
||||
if !freecam:
|
||||
if Input.is_action_just_pressed("jump") and is_on_floor():
|
||||
velocity.y = JUMP_VELOCITY
|
||||
|
||||
if freecam:
|
||||
if Input.is_action_pressed("jump"):
|
||||
velocity.y = JUMP_VELOCITY
|
||||
elif Input.is_action_pressed("descend"):
|
||||
velocity.y = -JUMP_VELOCITY
|
||||
else:
|
||||
velocity.y = 0
|
||||
|
||||
if Input.is_action_just_pressed("freecam"):
|
||||
freecam = !freecam
|
||||
|
||||
var input_dir: Vector2 = Input.get_vector("move_left", "move_right", "move_forwards", "move_backwards")
|
||||
var direction: Vector3 = (transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
|
||||
|
|
Loading…
Reference in a new issue