rmb for aiming
This commit is contained in:
@@ -184,6 +184,8 @@ func _process(delta: float) -> void:
|
||||
var look_at_pos := player.global_position + Vector3(0, 0.8, 0)
|
||||
camera.global_position = camera.global_position.lerp(look_at_pos + offset, 14.0 * delta)
|
||||
camera.look_at(look_at_pos, Vector3.UP)
|
||||
if Input.is_mouse_button_pressed(MOUSE_BUTTON_RIGHT):
|
||||
player.set_aim_direction(deg_to_rad(cam_yaw))
|
||||
|
||||
# ─── Player ───────────────────────────────────────────────────────────────────
|
||||
|
||||
|
||||
+13
-2
@@ -16,6 +16,9 @@ var invincible_timer: float = 0.0
|
||||
var is_alive: bool = true
|
||||
var last_move_dir: Vector3 = Vector3.FORWARD
|
||||
|
||||
var _aim_yaw: float = 0.0
|
||||
var _is_aiming: bool = false
|
||||
|
||||
@onready var mesh_node: MeshInstance3D = $BodyMesh
|
||||
@onready var indicator_node: MeshInstance3D = $KickIndicator
|
||||
|
||||
@@ -96,11 +99,15 @@ func _handle_movement(delta: float) -> void:
|
||||
velocity.x = move.x * move_speed
|
||||
velocity.z = move.z * move_speed
|
||||
last_move_dir = move
|
||||
var target_y: float = atan2(-move.x, -move.z)
|
||||
rotation.y = lerp_angle(rotation.y, target_y, 16.0 * delta)
|
||||
if not _is_aiming:
|
||||
var target_y: float = atan2(-move.x, -move.z)
|
||||
rotation.y = lerp_angle(rotation.y, target_y, 16.0 * delta)
|
||||
else:
|
||||
velocity.x = move_toward(velocity.x, 0.0, move_speed * 12.0 * delta)
|
||||
velocity.z = move_toward(velocity.z, 0.0, move_speed * 12.0 * delta)
|
||||
if _is_aiming:
|
||||
rotation.y = lerp_angle(rotation.y, _aim_yaw, 14.0 * delta)
|
||||
_is_aiming = false
|
||||
velocity.y = 0.0
|
||||
move_and_slide()
|
||||
|
||||
@@ -142,6 +149,10 @@ func _do_kick() -> void:
|
||||
if kicked_any:
|
||||
_squish_effect()
|
||||
|
||||
func set_aim_direction(yaw_rad: float) -> void:
|
||||
_aim_yaw = yaw_rad
|
||||
_is_aiming = true
|
||||
|
||||
func _squish_effect() -> void:
|
||||
var tw := create_tween()
|
||||
tw.tween_property(mesh_node, "scale", Vector3(1.3, 0.55, 1.3), 0.07)
|
||||
|
||||
Reference in New Issue
Block a user