Compare commits

...

5 Commits

5 changed files with 36 additions and 10 deletions

View File

@ -410,9 +410,18 @@ func _check_contacts() -> void:
var other := _body_state.get_contact_collider_object(i)
if other is StaticBody3D:
var contact_normal := _body_state.get_contact_local_normal(i)
if acos(contact_normal.dot(ground_normal)) <= _max_slope_angle:
var diff_current_ground := acos(contact_normal.dot(
ground_normal
))
var diff_true_ground := acos(contact_normal.dot(
Vector3.UP if gravity_scale >= 0.0 else Vector3.DOWN
))
if (
diff_current_ground <= _max_slope_angle ||
diff_true_ground <= _max_slope_angle/2.0
):
new_ground += contact_normal
else:
elif diff_current_ground < PI - _max_slope_angle/2.0:
new_wall += contact_normal
# Along the way, handle collisions with other kinds of objects.
elif other is Character:
@ -580,7 +589,7 @@ func _do_standard_motion(delta: float) -> void:
!volitional_velocity.is_zero_approx() &&
acos(ground_normal.dot(
Vector3.UP if gravity_scale >= 0.0 else Vector3.DOWN
)) <= _max_slope_angle
)) <= _max_slope_angle/2.0
):
apply_central_impulse(
-volitional_velocity.normalized() *

View File

@ -184,3 +184,8 @@ pause={
"events": [Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":6,"pressure":0.0,"pressed":true,"script":null)
]
}
[rendering]
renderer/rendering_method="gl_compatibility"
renderer/rendering_method.mobile="gl_compatibility"

View File

@ -4,7 +4,7 @@
[ext_resource type="Texture2D" uid="uid://dnhbrrbtx13vi" path="res://vfx/textures/skybox2.png" id="2_sj3fr"]
[ext_resource type="PackedScene" uid="uid://cp3qagrsuarl5" path="res://test/blender_test_map.blend" id="2_vhybo"]
[ext_resource type="PackedScene" uid="uid://gis0gxap8i8t" path="res://test/test_stick.tscn" id="3_sj3fr"]
[ext_resource type="Material" uid="uid://m4x75hyx6hih" path="res://maps/textures/brick1.tres" id="3_vhybo"]
[ext_resource type="Material" uid="uid://cdfukdmfwe6ub" path="res://maps/textures/crystal2.tres" id="4_p5rwy"]
[ext_resource type="PackedScene" uid="uid://b7mqd4ps8e3uj" path="res://props/springboard.tscn" id="8_p5rwy"]
[ext_resource type="Script" uid="uid://16os114krms3" path="res://characters/controllers/player_character_controller.gd" id="9_j70wf"]
[ext_resource type="Script" uid="uid://dotkfe7cs5010" path="res://test/pick_up_item.gd" id="10_ld4ib"]
@ -48,7 +48,7 @@ transform = Transform3D(1, 0, 0, 0, 0.5, 0.866025, 0, -0.866025, 0.5, 0, 100, 0)
[node name="blender_test_map" parent="StaticBody3D" instance=ExtResource("2_vhybo")]
[node name="Plane" parent="StaticBody3D/blender_test_map" index="0"]
surface_material_override/0 = ExtResource("3_vhybo")
surface_material_override/0 = ExtResource("4_p5rwy")
[node name="CollisionShape3D" type="CollisionShape3D" parent="StaticBody3D"]
shape = SubResource("ConcavePolygonShape3D_jy2qr")

View File

@ -311,7 +311,7 @@ collider_length = 1.0
collider_radius = 0.25
collider_horizontal = false
yaw_orientation = 0
pitch_orientation = 1
pitch_orientation = 3
orientation_speed = 600.0
counts_as_grounded = false
physics_mode = 0

View File

@ -6,6 +6,7 @@ class_name GameplayCamera extends Camera3D
@export var target_max_distance: float = 10.0
@export var target_decentering_factor: float = 0.4
@export var target_leveling_bias: float = 20.0
@export var allow_losing_target := false
@export var follow_lerp_speed: float = 0.999
@export var turn_lerp_speed: float = 0.999
@export var fov_lerp_speed: float = 0.999
@ -81,20 +82,31 @@ func _respond_to_impetus(delta: float) -> void:
)
look_impetus = Vector3.ZERO
func _try_go(where: Vector3) -> void:
_raycast_object.from = global_position
func _try_go(where: Vector3, from: Vector3 = global_position) -> void:
_raycast_object.from = from
_raycast_object.to = where + (
(where - global_position).normalized()*clip_margin
)
if target:
_raycast_object.exclude = [target]
else:
_raycast_object.exclude = []
var raycast_results := (
get_world_3d().direct_space_state.intersect_ray(_raycast_object)
)
var desired_position: Vector3
if raycast_results.is_empty():
global_position = where
desired_position = where
else:
global_position = raycast_results.position + (
desired_position = raycast_results.position + (
raycast_results.normal*clip_margin
)
if target && !allow_losing_target:
allow_losing_target = true
_try_go(desired_position, target.global_position)
allow_losing_target = false
else:
global_position = desired_position
func snap_to_target() -> void:
if !target: return