manage smal step

This commit is contained in:
AleaJactaEst 2022-02-09 23:36:58 +01:00
parent 3a737f0888
commit f39c3d1ff6
4 changed files with 121 additions and 89 deletions

1
.gitignore vendored
View file

@ -2,3 +2,4 @@
.godot/
Godot.zip
Godot_v4*linux.64
*.old

View file

@ -5,81 +5,53 @@
[node name="character" instance=ExtResource( "1_fjis3" )]
[node name="Skeleton3D" parent="char_grp/rig" index="0"]
bones/2/position = Vector3(-0.0168953, 0.508946, 0.0291032)
bones/3/rotation = Quaternion(0.0770252, 0.0061187, -0.0212199, 0.996785)
bones/5/position = Vector3(-0.338156, 0.447438, -0.124041)
bones/5/rotation = Quaternion(-0.307262, -0.314094, -0.387365, 0.810484)
bones/6/rotation = Quaternion(-1.33212e-07, 0.587936, 2.74967e-07, 0.808907)
bones/10/position = Vector3(0.00813095, 0.0408708, -0.108271)
bones/10/rotation = Quaternion(-0.0316695, 0.99443, 0.0903084, 0.0441596)
bones/11/rotation = Quaternion(-0.0554995, 0.082172, -0.0341149, 0.994487)
bones/12/rotation = Quaternion(-0.00305444, 0.025317, 0.0780189, 0.996626)
bones/16/rotation = Quaternion(-0.556256, 0.383694, 0.301203, 0.672781)
bones/17/rotation = Quaternion(-0.141952, 0.0631606, 0.424369, 0.89206)
bones/21/rotation = Quaternion(-0.545859, -0.416195, -0.418758, 0.594526)
bones/23/rotation = Quaternion(-0.0614123, -0.0911368, -0.507933, 0.854358)
bones/26/rotation = Quaternion(-0.092396, -0.012508, -0.016474, 0.995508)
bones/35/rotation = Quaternion(0.213681, -0.169249, -0.44672, 0.852136)
bones/36/rotation = Quaternion(0.0247409, -0.037012, 0.820981, 0.569217)
bones/38/rotation = Quaternion(0.453842, 0.608797, -0.453608, 0.466513)
bones/39/rotation = Quaternion(0.00476178, 0.990816, 0.135133, 0.000459045)
bones/40/rotation = Quaternion(0.296613, -3.00156e-08, -0.396533, 0.868782)
bones/46/rotation = Quaternion(0.108501, 0.138792, 0.458381, 0.871121)
bones/47/rotation = Quaternion(0.0456323, -0.0606414, -0.827615, 0.556142)
bones/49/rotation = Quaternion(0.280632, -0.521484, 0.48779, 0.641374)
bones/51/rotation = Quaternion(0.179271, -2.5339e-08, 0.4356, 0.882108)
bones/54/position = Vector3(0.312623, 0.437755, -0.109832)
bones/54/rotation = Quaternion(-0.337628, 0.316336, 0.395958, 0.793194)
bones/55/rotation = Quaternion(0.220858, -0.415893, -0.0365474, 0.88143)
bones/58/rotation = Quaternion(-0.178058, -0.000701349, -0.0247728, 0.983708)
bones/61/rotation = Quaternion(-0.102877, -0.00071574, -0.0123909, 0.994617)
bones/63/rotation = Quaternion(-0.0472496, -0.000244748, -0.00575957, 0.998866)
bones/66/rotation = Quaternion(-0.234863, 0.000405445, -0.0293189, 0.971586)
bones/69/rotation = Quaternion(-0.0621532, 0.000344386, -0.00745976, 0.998039)
bones/71/rotation = Quaternion(-0.0202359, -0.000526936, -0.00241824, 0.999792)
bones/74/rotation = Quaternion(-0.118501, -0.00204265, -0.00167214, 0.99295)
bones/77/rotation = Quaternion(-0.0608605, -6.15146e-05, -0.00731642, 0.998119)
bones/79/rotation = Quaternion(-0.0215469, -0.000118847, -0.0025894, 0.999765)
bones/82/rotation = Quaternion(-0.045812, 0.0774554, -0.0426766, 0.995028)
bones/85/rotation = Quaternion(-0.341894, -0.0505131, -0.00712847, 0.938353)
bones/87/rotation = Quaternion(-0.112437, -0.0105561, -0.016501, 0.993466)
bones/90/rotation = Quaternion(-0.226489, 0.0119206, 0.0152102, 0.973822)
bones/93/rotation = Quaternion(-0.0421871, 5.92849e-06, -0.00505668, 0.999097)
bones/95/rotation = Quaternion(-0.00828159, -0.000121388, -0.000993767, 0.999965)
bones/96/position = Vector3(0.26788, -0.0799248, -0.461465)
bones/96/rotation = Quaternion(0.495633, 0.199817, 0.813215, 0.230442)
bones/97/rotation = Quaternion(8.85872e-08, 0.0024306, -5.89807e-10, 0.999997)
bones/101/position = Vector3(0.312623, 0.437755, -0.109832)
bones/101/rotation = Quaternion(-0.337628, 0.316336, 0.395958, 0.793194)
bones/104/rotation = Quaternion(-2.57163e-07, -0.424214, -1.98708e-07, 0.905562)
bones/106/position = Vector3(-0.23823, 0.429048, -0.0548472)
bones/106/rotation = Quaternion(-0.431817, 0.089361, 0.488602, 0.752872)
bones/109/position = Vector3(0.162602, -0.0317358, -0.27701)
bones/109/rotation = Quaternion(-0.381183, 0.322201, -0.682154, 0.53437)
bones/112/position = Vector3(-0.253918, -0.103652, -0.463478)
bones/112/rotation = Quaternion(0.433082, -0.134603, -0.846937, 0.277523)
bones/115/rotation = Quaternion(-1.31103e-07, 0.048314, 5.07712e-08, 0.998832)
bones/117/position = Vector3(-0.338156, 0.447438, -0.124041)
bones/117/rotation = Quaternion(-0.307262, -0.314094, -0.387365, 0.810484)
bones/118/rotation = Quaternion(0.1203, 0.584517, 0.0686503, 0.799472)
bones/121/rotation = Quaternion(-0.0553657, 0.093504, 0.059485, 0.992297)
bones/124/rotation = Quaternion(-0.130073, 0.0138176, -0.00793818, 0.991376)
bones/126/rotation = Quaternion(0.0566031, -0.00251201, 0.0386277, 0.997646)
bones/129/rotation = Quaternion(0.000190053, -0.00104534, 0.00800264, 0.999968)
bones/132/rotation = Quaternion(-0.0190412, 0.000132444, 0.00227098, 0.999816)
bones/134/rotation = Quaternion(-0.0647147, 0.000386823, 0.00777492, 0.997873)
bones/137/rotation = Quaternion(0.00235471, -0.00315775, 0.0401739, 0.999185)
bones/140/rotation = Quaternion(-0.0165778, 0.0003923, -0.0339278, 0.999287)
bones/142/rotation = Quaternion(-0.0201405, 0.000293718, 0.00239391, 0.999794)
bones/145/rotation = Quaternion(-0.0346762, 0.00433396, 0.039094, 0.998624)
bones/148/rotation = Quaternion(-8.86981e-05, -4.99268e-07, 1.03173e-05, 1)
bones/150/rotation = Quaternion(-0.00112873, 2.94077e-05, 0.000133846, 0.999999)
bones/153/rotation = Quaternion(-0.0254682, -0.00272336, 0.00153101, 0.999671)
bones/156/rotation = Quaternion(-0.000252583, 2.31054e-07, 2.96366e-05, 1)
bones/159/position = Vector3(-0.147036, -0.0462964, -0.282602)
bones/159/rotation = Quaternion(-0.381505, -0.31016, 0.697233, 0.521652)
bones/162/position = Vector3(0.20413, 0.430834, -0.0524523)
bones/162/rotation = Quaternion(-0.438851, -0.149045, -0.528447, 0.711294)
bones/2/position = Vector3(-0.00506478, 0.466326, 0.942895)
bones/3/rotation = Quaternion(-0.133785, -0.0316834, 0.071252, 0.987938)
bones/5/position = Vector3(-0.218553, 0.126083, 0.922158)
bones/5/rotation = Quaternion(-0.715018, 0.0661517, 0.662421, 0.213475)
bones/6/rotation = Quaternion(-1.3178e-07, 0.0114362, 3.58596e-07, 0.999935)
bones/10/position = Vector3(-0.00191097, -0.0125695, 0.857793)
bones/10/rotation = Quaternion(0.00623195, 0.99891, -0.0462335, 0.00168693)
bones/11/rotation = Quaternion(-0.167316, 0.020861, -0.00928351, 0.985639)
bones/12/rotation = Quaternion(0.006424, 0.0132741, -0.00297561, 0.999887)
bones/16/rotation = Quaternion(-0.656904, 0.253208, 0.332021, 0.627793)
bones/17/rotation = Quaternion(-0.509886, -0.0544441, 0.172774, 0.840953)
bones/21/rotation = Quaternion(-0.575522, -0.37039, -0.451503, 0.572477)
bones/23/rotation = Quaternion(-0.492885, 0.0813709, -0.0822871, 0.862364)
bones/26/rotation = Quaternion(-0.029083, 0.00179413, -0.0257357, 0.999244)
bones/35/rotation = Quaternion(0.103596, -0.0863059, -0.0483063, 0.98969)
bones/36/rotation = Quaternion(0.039159, -0.0748465, 0.26351, 0.960951)
bones/38/rotation = Quaternion(0.281259, 0.566062, -0.451518, 0.629761)
bones/39/rotation = Quaternion(0.00479683, 0.989189, 0.146566, 0.000713159)
bones/40/rotation = Quaternion(0.107401, -3.18739e-08, -0.0391236, 0.993446)
bones/46/rotation = Quaternion(0.214792, 0.222058, 0.00962893, 0.951032)
bones/47/rotation = Quaternion(0.0335214, 0.0695326, -0.186123, 0.97949)
bones/49/rotation = Quaternion(0.248496, -0.66888, 0.30841, 0.629073)
bones/50/rotation = Quaternion(-0.00467455, 0.994189, 0.107551, 0.000154286)
bones/51/rotation = Quaternion(0.211355, -2.09798e-08, -0.0394617, 0.976612)
bones/54/position = Vector3(0.196354, 0.122889, 0.914004)
bones/54/rotation = Quaternion(-0.416081, 0.00519037, -0.872079, 0.257542)
bones/55/rotation = Quaternion(-0.179861, -0.15027, -0.0187863, 0.971965)
bones/96/position = Vector3(0.224384, -0.433829, 0.887285)
bones/96/rotation = Quaternion(-0.373285, -0.213196, -0.902139, 0.0367621)
bones/97/rotation = Quaternion(9.63929e-08, -0.0209701, -1.19635e-07, 0.99978)
bones/101/position = Vector3(0.196354, 0.122889, 0.914004)
bones/101/rotation = Quaternion(-0.416081, 0.0051903, -0.872079, 0.257542)
bones/104/rotation = Quaternion(-2.77398e-07, -0.152845, -2.43311e-07, 0.98825)
bones/106/position = Vector3(-0.170355, 0.239115, 0.925624)
bones/106/rotation = Quaternion(-0.7052, 0.13406, 0.68003, 0.149266)
bones/109/position = Vector3(0.135571, -0.235057, 0.881648)
bones/109/rotation = Quaternion(-0.46927, -0.111662, -0.857984, 0.17658)
bones/112/position = Vector3(-0.158349, -0.451938, 0.808648)
bones/112/rotation = Quaternion(0.509246, -0.191365, -0.838008, 0.042307)
bones/115/rotation = Quaternion(2.14026e-08, 0.0120989, -5.34386e-08, 0.999927)
bones/117/position = Vector3(-0.218554, 0.126083, 0.922158)
bones/117/rotation = Quaternion(-0.715018, 0.0661503, 0.662421, 0.213473)
bones/118/rotation = Quaternion(-0.0306712, 0.0114382, -0.00100564, 0.999464)
bones/159/position = Vector3(-0.10482, -0.243509, 0.842137)
bones/159/rotation = Quaternion(-0.600852, 0.0137189, 0.785812, 0.145904)
bones/162/position = Vector3(0.150024, 0.235589, 0.930238)
bones/162/rotation = Quaternion(-0.415601, -0.0206444, -0.886383, 0.202918)
[node name="AnimationPlayer" parent="." index="1"]
autoplay = "CHAR_idle_bored"

View file

@ -24,10 +24,12 @@ const ZOOM_MAX_Z = 3.0
const SPEED_ROTATE = PI
const PI_2 = PI / 2.0
const JUMP_FORCE = 4.5
const STEP_FORCE = 30.0
const MUL_SPEED_FLY = 2.0
const MUL_SPEED_SWIM = 0.5
const FACTOR_WALK_WATER = 0.3
const MUL_SPEED_STEP = 0.4
# Get the gravity from the project settings to be synced with RigidDynamicBody nodes.
var gravity = ProjectSettings.get_setting("physics/3d/default_gravity")
@ -80,6 +82,7 @@ var player_automove:bool = false
var state_player:StatePlayer = StatePlayer.WALK
var level_water:float
var heigh_underwater = 1.0
var stop_move:bool = false
@onready var camera_fps:Camera3D = $camera_root/Camera3D_FPS_WALK
@ -164,8 +167,10 @@ func _on_AnimationPlayer_animation_finished(name:String):
func _init():
print("wall_min_slide_angle: ", get_wall_min_slide_angle())
print("get_floor_max_angle: ", get_floor_max_angle())
print("get_floor_snap_length: ", get_floor_snap_length())
# set_wall_min_slide_angle(1.0)
set_floor_max_angle(4.0)
#set_floor_max_angle(4.0)
# set_floor_snap_length(0.4)
pass
@ -173,6 +178,7 @@ func _init():
func _ready():
# Place the mouse at the center of the screen
get_viewport().warp_mouse(starting_point)
#$RayCastGround.rotate_x( -get_floor_max_angle() )
search_animation($Mesh/character, "/")
print_list_animation()
switch_state(StatePlayer.WALK)
@ -263,6 +269,8 @@ func _input(event):
func _physics_process(delta):
# Add the gravity.
if stop_move:
return
match state_player:
StatePlayer.WALK_WATER:
if get_position().y > level_water - heigh_underwater:
@ -286,6 +294,8 @@ func _physics_process_walk(delta):
var move_up:bool = false
var move_down:bool = false
var move_strafe: bool = false
#var step: bool = false
var mulstep: float = 1.0
#print(get_position())
# Add the gravity.
@ -392,18 +402,25 @@ func _physics_process_walk(delta):
switch_animation(anim_sitting_ground_idle)
else:
switch_animation(anim_idle)
if is_on_floor() and (input_x != 0.0 or input_y != 0.0) and $RayCastGround.is_colliding() and !$RayCastStep.is_colliding():
motion_velocity.y = STEP_FORCE
move_and_slide()
motion_velocity.y = -STEP_FORCE
#step = true
mulstep = MUL_SPEED_STEP
var direction = (transform.basis * Vector3(input_x, 0, input_y)).normalized()
if direction:
motion_velocity.x = direction.x * speed
motion_velocity.z = direction.z * speed
motion_velocity.x = direction.x * speed * mulstep
motion_velocity.z = direction.z * speed * mulstep
else:
motion_velocity.x = move_toward(motion_velocity.x, 0, speed)
motion_velocity.z = move_toward(motion_velocity.z, 0, speed)
motion_velocity.x = move_toward(motion_velocity.x, 0, speed * mulstep)
motion_velocity.z = move_toward(motion_velocity.z, 0, speed * mulstep)
#print("pos:", get_floor_angle(), " - ", get_wall_min_slide_angle(), " - ", get_floor_max_angle())
#motion_velocity.y = 0.5
move_and_slide()
#print(">>> motion_velocity:", motion_velocity, " position:", get_position())
var collided = move_and_slide()
if collided:
print("+++++++++++: ", get_last_slide_collision().get_position(), " <> ", get_position())
func _physics_process_walk_water(delta):

View file

@ -1,14 +1,26 @@
[gd_scene load_steps=6 format=3 uid="uid://dwxrvijqyym70"]
[gd_scene load_steps=9 format=3 uid="uid://dwxrvijqyym70"]
[ext_resource type="Script" path="res://player/player.gd" id="1_myhjw"]
[ext_resource type="PackedScene" uid="uid://cjklxedjnvc1c" path="res://player/character/character.tscn" id="1_rqqo8"]
[ext_resource type="Script" path="res://player/camera.gd" id="2_xvdvx"]
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_a1omj"]
radius = 0.446849
height = 1.52436
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_b1r1o"]
radius = 0.781675
height = 1.69837
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_w6qjk"]
radius = 0.220923
height = 2.83965
[sub_resource type="PlaneMesh" id="PlaneMesh_mwqg4"]
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_645as"]
radius = 0.608862
height = 1.69456
[sub_resource type="PlaneMesh" id="PlaneMesh_p36im"]
[node name="player" type="CharacterBody3D"]
script = ExtResource( "1_myhjw" )
@ -17,11 +29,31 @@ script = ExtResource( "1_myhjw" )
[node name="character" parent="Mesh" instance=ExtResource( "1_rqqo8" )]
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
[node name="CollisionFly" type="CollisionShape3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 0, -1, 0, 1, 0, 0, 0.994976, -0.258262)
visible = false
shape = SubResource( "CapsuleShape3D_a1omj" )
disabled = true
[node name="CollisionFlyIdle" type="CollisionShape3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.27688, 0)
visible = false
shape = SubResource( "CapsuleShape3D_b1r1o" )
disabled = true
[node name="CollisionWalk" type="CollisionShape3D" parent="."]
transform = Transform3D(0.999787, 0, 0, 0, 0.589349, 0, 0, 0, 0.371542, 0, 0.836561, 0)
visible = false
shape = SubResource( "CapsuleShape3D_w6qjk" )
[node name="CollisionSwim" type="CollisionShape3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 0, -1, 0, 1, 0, 0, 0, 0)
visible = false
shape = SubResource( "CapsuleShape3D_645as" )
disabled = true
[node name="camera_root" type="Node3D" parent="."]
visible = false
script = ExtResource( "2_xvdvx" )
[node name="horizontal_root" type="Node3D" parent="camera_root"]
@ -34,13 +66,23 @@ transform = Transform3D(-1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 0, 0,
[node name="Camera3D_FPS_WALK" type="Camera3D" parent="camera_root"]
transform = Transform3D(-1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 0, 1.56633, 0.222061)
visible = false
[node name="Camera3D_FPS_FLY" type="Camera3D" parent="camera_root"]
transform = Transform3D(-1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 0, 1.09195, 0.571561)
visible = false
[node name="Camera3D_FPS_SWIM" type="Camera3D" parent="camera_root"]
transform = Transform3D(-1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 0, 0.148843, 0.633556)
[node name="carpet" type="MeshInstance3D" parent="."]
visible = false
mesh = SubResource( "PlaneMesh_mwqg4" )
[node name="RayCastGround" type="RayCast3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 0, 1, 0, -0.3, 0, 0, 0.01, 0)
[node name="MeshInstance3D" type="MeshInstance3D" parent="RayCastGround"]
transform = Transform3D(0.2, 0, 0, 0, 0, -10, 0, 1, 0, 0, 0, 0)
visible = false
mesh = SubResource( "PlaneMesh_p36im" )
[node name="RayCastStep" type="RayCast3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 0, 1, 0, -0.3, 0, 0, 0.4, 0)