mirror of
https://gitlab.com/open-fpsz/open-fpsz.git
synced 2026-01-19 19:44:46 +00:00
🐛 fix player motion computation
This commit is contained in:
parent
fae82c45f8
commit
01f86cd78d
|
|
@ -277,19 +277,18 @@ func _integrate_forces(_state:PhysicsDirectBodyState3D) -> void:
|
|||
# retrieve collision normal
|
||||
var normal:Vector3 = walkable_surface_sensor.get_collision_normal(0)
|
||||
|
||||
if not view_direction.is_zero_approx() and not input.skiing:
|
||||
if not input.direction.is_zero_approx():
|
||||
if not input.skiing:
|
||||
# calculate the angle between the ground normal and the up vector
|
||||
var slope_angle:float = rad_to_deg(acos(normal.dot(Vector3.UP)))
|
||||
# check if the slope angle exceeds the maximum slope angle
|
||||
if slope_angle <= max_floor_angle:
|
||||
# adjust direction based on the floor normal to align with the slope
|
||||
view_direction = view_direction.slide(normal)
|
||||
|
||||
linear_velocity = lerp(linear_velocity, view_direction * ground_speed, .1)
|
||||
var direction_on_surface:Vector3 = normal.cross(
|
||||
view_direction.cross(normal)).normalized()
|
||||
apply_central_impulse(mass * (direction_on_surface * ground_speed - linear_velocity) * .1)
|
||||
|
||||
if _jumping:
|
||||
var v:float = sqrt(2. * g * jump_height)
|
||||
apply_central_impulse(Vector3(0., mass * v, 0.))
|
||||
apply_central_impulse(Vector3(0., mass * sqrt(2 * g * jump_height), 0.))
|
||||
|
||||
_jumping = false
|
||||
|
||||
|
|
|
|||
|
|
@ -256,7 +256,6 @@ tp_mesh = NodePath("ThirdPerson/Mesh")
|
|||
third_person = NodePath("ThirdPerson")
|
||||
pivot = NodePath("Pivot")
|
||||
camera = NodePath("Pivot/Camera3D")
|
||||
max_floor_angle = 80.0
|
||||
input = NodePath("Inputs")
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
|
||||
|
|
@ -400,27 +399,15 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2.6068e-14, -1.19209e-07, 9.5
|
|||
[node name="sides" parent="ThirdPerson/Mesh/Node/Skeleton3D/HandAttachment/SpaceGun/Mesh/Armature/Skeleton3D/sides" index="0"]
|
||||
layers = 2
|
||||
|
||||
[node name="BarrelsInner" parent="ThirdPerson/Mesh/Node/Skeleton3D/HandAttachment/ChainGun/Armature/Skeleton3D" index="0"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.692504, 1.30946)
|
||||
|
||||
[node name="BarrelsInner" parent="ThirdPerson/Mesh/Node/Skeleton3D/HandAttachment/ChainGun/Armature/Skeleton3D/BarrelsInner" index="0"]
|
||||
layers = 2
|
||||
|
||||
[node name="BarrelsOuter" parent="ThirdPerson/Mesh/Node/Skeleton3D/HandAttachment/ChainGun/Armature/Skeleton3D" index="1"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.692504, 1.30946)
|
||||
|
||||
[node name="BarrelsOuter" parent="ThirdPerson/Mesh/Node/Skeleton3D/HandAttachment/ChainGun/Armature/Skeleton3D/BarrelsOuter" index="0"]
|
||||
layers = 2
|
||||
|
||||
[node name="Base" parent="ThirdPerson/Mesh/Node/Skeleton3D/HandAttachment/ChainGun/Armature/Skeleton3D" index="2"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.692504, 1.30946)
|
||||
|
||||
[node name="Base" parent="ThirdPerson/Mesh/Node/Skeleton3D/HandAttachment/ChainGun/Armature/Skeleton3D/Base" index="0"]
|
||||
layers = 2
|
||||
|
||||
[node name="Grip" parent="ThirdPerson/Mesh/Node/Skeleton3D/HandAttachment/ChainGun/Armature/Skeleton3D" index="3"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.692504, 1.30946)
|
||||
|
||||
[node name="Grip" parent="ThirdPerson/Mesh/Node/Skeleton3D/HandAttachment/ChainGun/Armature/Skeleton3D/Grip" index="0"]
|
||||
layers = 2
|
||||
|
||||
|
|
@ -433,21 +420,12 @@ bones/1/rotation = Quaternion(0, 0.707107, 0.707107, 0)
|
|||
bones/2/rotation = Quaternion(0, 0.707107, 0.707107, 0)
|
||||
bones/3/rotation = Quaternion(0, 0.707107, 0.707107, 0)
|
||||
|
||||
[node name="barrel" parent="ThirdPerson/Mesh/Node/Skeleton3D/HandAttachment/GrenadeLauncher/Armature/Skeleton3D" index="0"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.19209e-07, 0)
|
||||
|
||||
[node name="barrel" parent="ThirdPerson/Mesh/Node/Skeleton3D/HandAttachment/GrenadeLauncher/Armature/Skeleton3D/barrel" index="0"]
|
||||
layers = 2
|
||||
|
||||
[node name="grip" parent="ThirdPerson/Mesh/Node/Skeleton3D/HandAttachment/GrenadeLauncher/Armature/Skeleton3D" index="1"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.082471, -0.0653242)
|
||||
|
||||
[node name="grip" parent="ThirdPerson/Mesh/Node/Skeleton3D/HandAttachment/GrenadeLauncher/Armature/Skeleton3D/grip" index="0"]
|
||||
layers = 2
|
||||
|
||||
[node name="main" parent="ThirdPerson/Mesh/Node/Skeleton3D/HandAttachment/GrenadeLauncher/Armature/Skeleton3D" index="2"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.19209e-07, 0)
|
||||
|
||||
[node name="main" parent="ThirdPerson/Mesh/Node/Skeleton3D/HandAttachment/GrenadeLauncher/Armature/Skeleton3D/main" index="0"]
|
||||
layers = 2
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue