mirror of
https://github.com/thegatesbrowser/godot-multiplayer.git
synced 2025-10-16 02:03:43 -04:00
Update to 4.4.1
This commit is contained in:
parent
4ae45deca1
commit
ceb10e9a06
160 changed files with 491 additions and 71 deletions
|
@ -1,7 +1,7 @@
|
|||
class_name CameraController
|
||||
extends Node3D
|
||||
|
||||
@export_node_path var player_path : NodePath
|
||||
@export_node_path var player_path: NodePath
|
||||
@export var invert_mouse_y := false
|
||||
@export_range(0.0, 1.0) var mouse_sensitivity := 0.25
|
||||
@export_range(0.0, 8.0) var joystick_sensitivity := 2.0
|
||||
|
@ -29,8 +29,32 @@ func _ready() -> void:
|
|||
func _unhandled_input(event: InputEvent) -> void:
|
||||
_mouse_input = event is InputEventMouseMotion and Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED
|
||||
if _mouse_input:
|
||||
_rotation_input = -event.relative.x * mouse_sensitivity
|
||||
_tilt_input = -event.relative.y * mouse_sensitivity
|
||||
_rotation_input = - event.relative.x * mouse_sensitivity
|
||||
_tilt_input = - event.relative.y * mouse_sensitivity
|
||||
|
||||
|
||||
func setup(anchor: CharacterBody3D) -> void:
|
||||
_anchor = anchor
|
||||
|
||||
# FIX: Don't preserve the initial offset - position the camera controller directly on the player
|
||||
# The old offset calculation was preserving incorrect initial positioning
|
||||
_offset = Vector3.ZERO # Remove any initial offset
|
||||
|
||||
# Position the camera controller directly on the player
|
||||
global_position = anchor.global_position
|
||||
|
||||
# CRITICAL FIX: Exclude the anchor from SpringArm3D collision detection
|
||||
# This prevents the camera from colliding with the character itself
|
||||
_camera_spring_arm.add_excluded_object(_anchor.get_rid())
|
||||
|
||||
# Also exclude the anchor's collision shape if it has one
|
||||
if _anchor.has_method("get_rid"):
|
||||
_camera_spring_arm.add_excluded_object(_anchor.get_rid())
|
||||
|
||||
# Additional fix: exclude all collision shapes from the character
|
||||
for child in _anchor.get_children():
|
||||
if child is CollisionShape3D:
|
||||
_camera_spring_arm.add_excluded_object(child.get_rid())
|
||||
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
|
@ -46,8 +70,9 @@ func _physics_process(delta: float) -> void:
|
|||
if invert_mouse_y:
|
||||
_tilt_input *= -1
|
||||
|
||||
# Set camera controller to current ground level for the character
|
||||
var target_position := _anchor.global_position + _offset
|
||||
# FIX: Position camera controller directly on player, not with offset
|
||||
# Set camera controller to follow the player's position
|
||||
var target_position := _anchor.global_position
|
||||
target_position.y = lerp(global_position.y, _anchor._ground_height, 0.1)
|
||||
global_position = target_position
|
||||
|
||||
|
@ -58,15 +83,9 @@ func _physics_process(delta: float) -> void:
|
|||
|
||||
transform.basis = Basis.from_euler(_euler_rotation)
|
||||
|
||||
# Ensure the camera follows the spring arm pivot properly
|
||||
camera.global_transform = _pivot.global_transform
|
||||
camera.rotation.z = 0
|
||||
|
||||
_rotation_input = 0.0
|
||||
_tilt_input = 0.0
|
||||
|
||||
|
||||
func setup(anchor: CharacterBody3D) -> void:
|
||||
_anchor = anchor
|
||||
_offset = global_transform.origin - anchor.global_transform.origin
|
||||
camera.global_transform = camera.global_transform.interpolate_with(_pivot.global_transform, 0.1)
|
||||
_camera_spring_arm.add_excluded_object(_anchor.get_rid())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue