fixed a bit better lightning
This commit is contained in:
@@ -6,10 +6,11 @@ extends CharacterBody2D
|
||||
var character_stats: CharacterStats
|
||||
var appearance_rng: RandomNumberGenerator # Deterministic RNG for appearance/stats
|
||||
|
||||
@export var move_speed: float = 80.0
|
||||
@export var move_speed: float = 65.0 # Base move speed (not affected by DEX)
|
||||
@export var grab_range: float = 20.0
|
||||
@export var base_throw_force: float = 80.0 # Base throw force (reduced from 150), scales with STR
|
||||
@export var cone_light_angle: float = 180.0 # Cone spread angle in degrees (adjustable, default wider)
|
||||
const CONE_LIGHT_LERP_SPEED: float = 12.0 # How quickly cone rotation follows target (higher = snappier)
|
||||
|
||||
# Network identity
|
||||
var peer_id: int = 1
|
||||
@@ -1743,16 +1744,13 @@ func _update_facing_from_mouse(mouse_direction: Vector2):
|
||||
# Mark that mouse control is active (prevents movement keys from overriding attack direction)
|
||||
mouse_control_active = true
|
||||
|
||||
# Store full 360-degree direction for attacks
|
||||
# Store full 360-degree direction for attacks (cone light uses this for smooth rotation)
|
||||
if mouse_direction.length() > 0.1:
|
||||
facing_direction_vector = mouse_direction.normalized()
|
||||
|
||||
var new_direction = _get_direction_from_vector(mouse_direction) as Direction
|
||||
|
||||
# Update direction and cone light rotation if changed
|
||||
if new_direction != current_direction:
|
||||
current_direction = new_direction
|
||||
_update_cone_light_rotation()
|
||||
|
||||
func _set_animation(anim_name: String):
|
||||
if current_animation != anim_name:
|
||||
@@ -1782,10 +1780,18 @@ func _direction_to_angle(direction: int) -> float:
|
||||
_:
|
||||
return PI / 2.0 # Default to DOWN
|
||||
|
||||
# Update cone light rotation based on player's facing direction
|
||||
func _update_cone_light_rotation():
|
||||
if cone_light:
|
||||
cone_light.rotation = _direction_to_angle(current_direction) + (PI / 2)
|
||||
# Update cone light rotation based on facing (lerps toward target for smooth 360° movement)
|
||||
func _update_cone_light_rotation(delta: float = 1.0):
|
||||
if not cone_light:
|
||||
return
|
||||
var target_angle: float
|
||||
if facing_direction_vector.length() > 0.1:
|
||||
target_angle = facing_direction_vector.angle() + (PI / 2.0)
|
||||
else:
|
||||
target_angle = _direction_to_angle(current_direction) + (PI / 2.0)
|
||||
# Lerp toward target (delta=1.0 in _ready snaps; in _physics_process uses smooth follow)
|
||||
var t = 1.0 - exp(-CONE_LIGHT_LERP_SPEED * delta)
|
||||
cone_light.rotation = lerp_angle(cone_light.rotation, target_angle, t)
|
||||
|
||||
# Create a cone-shaped light texture programmatically
|
||||
# Creates a directional cone texture that extends forward and fades to the sides
|
||||
@@ -2511,25 +2517,17 @@ func _handle_input():
|
||||
var new_direction = _get_direction_from_vector(shield_block_direction) as Direction
|
||||
if new_direction != current_direction:
|
||||
current_direction = new_direction
|
||||
_update_cone_light_rotation()
|
||||
elif not is_pushing and (not mouse_control_active or input_device != -1) and direction_lock_timer <= 0.0:
|
||||
var new_direction = _get_direction_from_vector(input_vector) as Direction
|
||||
|
||||
# Update direction and cone light rotation if changed
|
||||
if new_direction != current_direction:
|
||||
current_direction = new_direction
|
||||
_update_cone_light_rotation()
|
||||
elif direction_lock_timer > 0.0 and locked_facing_direction.length() > 0.0:
|
||||
# Use locked direction for animations during attack
|
||||
var new_direction = _get_direction_from_vector(locked_facing_direction) as Direction
|
||||
if new_direction != current_direction:
|
||||
current_direction = new_direction
|
||||
_update_cone_light_rotation()
|
||||
elif is_pushing or (held_object and not is_lifting):
|
||||
# Keep direction from when grab started (don't turn to face the object)
|
||||
if push_direction_locked != current_direction:
|
||||
current_direction = push_direction_locked as Direction
|
||||
_update_cone_light_rotation()
|
||||
|
||||
# Set animation based on state
|
||||
if grabbed_by_enemy_hand:
|
||||
@@ -2571,20 +2569,20 @@ func _handle_input():
|
||||
elif is_pushing or (held_object and not is_lifting):
|
||||
if is_pushing:
|
||||
_set_animation("IDLE_PUSH")
|
||||
# Keep direction from when grab started
|
||||
if push_direction_locked != current_direction:
|
||||
current_direction = push_direction_locked as Direction
|
||||
_update_cone_light_rotation()
|
||||
elif is_shielding:
|
||||
# Keep locked block direction when shielding and idle
|
||||
var new_direction = _get_direction_from_vector(shield_block_direction) as Direction
|
||||
if new_direction != current_direction:
|
||||
current_direction = new_direction
|
||||
_update_cone_light_rotation()
|
||||
else:
|
||||
if current_animation != "THROW" and current_animation != "DAMAGE" and current_animation != "SWORD" and current_animation != "BOW" and current_animation != "STAFF" and current_animation != "AXE" and current_animation != "PUNCH" and current_animation != "CONJURE" and current_animation != "LIFT" and current_animation != "FINISH_SPELL":
|
||||
_set_animation("IDLE")
|
||||
|
||||
# Cone light lerps toward facing direction every frame (360°)
|
||||
if is_local_player and cone_light and cone_light.visible:
|
||||
_update_cone_light_rotation(get_physics_process_delta_time())
|
||||
|
||||
# Handle drag sound for interactable objects
|
||||
var is_dragging_now = false
|
||||
if held_object and is_pushing and not is_lifting:
|
||||
|
||||
Reference in New Issue
Block a user