Level Setup
Integrated with Trenchbroom
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
class_name PlayerController extends CharacterBody3D
|
||||
|
||||
signal hit_static_body(rid, position)
|
||||
|
||||
@export var debug: bool = false
|
||||
@export_category("References")
|
||||
@export var camera: CameraController
|
||||
@@ -30,6 +32,21 @@ var speed: float = 0.0
|
||||
var current_fall_velocity: float
|
||||
var previous_velocity: Vector3
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed("left_click"):
|
||||
var center = camera_effects.get_camera_center()
|
||||
var ray_orgin = camera_effects.project_ray_origin(center)
|
||||
var ray_end = ray_orgin + camera_effects.project_ray_normal(center) * 1000
|
||||
|
||||
var new_intersection = PhysicsRayQueryParameters3D.create(ray_orgin, ray_end)
|
||||
var query = get_world_3d().direct_space_state.intersect_ray(new_intersection)
|
||||
|
||||
if query:
|
||||
var collider = query["collider"]
|
||||
var wall = collider.get_parent().get_parent()
|
||||
if wall and wall is DestructableWall:
|
||||
wall.hit(query["position"])
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
previous_velocity = self.velocity
|
||||
|
||||
@@ -67,28 +84,22 @@ func update_rotation(rotation_input) -> void:
|
||||
func sprint() -> void:
|
||||
sprint_modifier = sprint_speed
|
||||
|
||||
|
||||
|
||||
func walk() -> void:
|
||||
sprint_modifier = 0.0
|
||||
|
||||
|
||||
func stand() -> void:
|
||||
crouch_modifier = 0.0
|
||||
standing_collision.disabled = false
|
||||
crouching_collision.disabled = true
|
||||
|
||||
|
||||
func crouch() -> void:
|
||||
crouch_modifier = crouch_speed
|
||||
standing_collision.disabled = true
|
||||
crouching_collision.disabled = false
|
||||
|
||||
|
||||
func jump() -> void:
|
||||
velocity.y += jump_velocity
|
||||
|
||||
|
||||
func check_fall_speed() -> bool:
|
||||
if current_fall_velocity < fall_velocity_threashold:
|
||||
current_fall_velocity = 0.0
|
||||
|
||||
Reference in New Issue
Block a user