move directory
This commit is contained in:
parent
1b44ccd206
commit
e5c01d4215
12 changed files with 410 additions and 56 deletions
File diff suppressed because one or more lines are too long
|
@ -9,3 +9,13 @@ func _on_underwater_body_entered(body):
|
||||||
func _on_underwater_body_exited(body):
|
func _on_underwater_body_exited(body):
|
||||||
if body.has_method("exit_underwater"):
|
if body.has_method("exit_underwater"):
|
||||||
body.exit_underwater()
|
body.exit_underwater()
|
||||||
|
|
||||||
|
|
||||||
|
func _on_area_3d_body_entered(body):
|
||||||
|
if body.has_method("enter_boat"):
|
||||||
|
body.enter_boat($delta_boat)
|
||||||
|
|
||||||
|
|
||||||
|
func _on_area_3d_body_exited(body):
|
||||||
|
if body.has_method("exit_boat"):
|
||||||
|
body.exit_boat($delta_boat)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
[gd_scene load_steps=14 format=3 uid="uid://bkcvep4ijijmc"]
|
[gd_scene load_steps=15 format=3 uid="uid://bkcvep4ijijmc"]
|
||||||
|
|
||||||
[ext_resource type="Shader" path="res://maps/shaders/water.gdshader" id="1_j5guc"]
|
[ext_resource type="Shader" path="res://maps/shaders/water.gdshader" id="1_j5guc"]
|
||||||
[ext_resource type="Script" path="res://maps/water-zone.gd" id="1_s4mf8"]
|
[ext_resource type="Script" path="res://maps/water-zone.gd" id="1_s4mf8"]
|
||||||
|
@ -8,6 +8,9 @@
|
||||||
[ext_resource type="Texture2D" uid="uid://b8tu2ncerig3r" path="res://maps/textures/water_normal_b.png" id="4_gohr5"]
|
[ext_resource type="Texture2D" uid="uid://b8tu2ncerig3r" path="res://maps/textures/water_normal_b.png" id="4_gohr5"]
|
||||||
[ext_resource type="Texture2D" uid="uid://dv1ywlb7inqyu" path="res://maps/textures/water_uv_sampler.png" id="5_uyeqp"]
|
[ext_resource type="Texture2D" uid="uid://dv1ywlb7inqyu" path="res://maps/textures/water_uv_sampler.png" id="5_uyeqp"]
|
||||||
|
|
||||||
|
[sub_resource type="SphereShape3D" id="SphereShape3D_08c7l"]
|
||||||
|
radius = 2.0
|
||||||
|
|
||||||
[sub_resource type="Texture2DArray" id="Texture2DArray_um4oc"]
|
[sub_resource type="Texture2DArray" id="Texture2DArray_um4oc"]
|
||||||
|
|
||||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_tfcq0"]
|
[sub_resource type="ShaderMaterial" id="ShaderMaterial_tfcq0"]
|
||||||
|
@ -71,6 +74,12 @@ script = ExtResource( "1_s4mf8" )
|
||||||
[node name="delta_boat" parent="." instance=ExtResource( "2_824w2" )]
|
[node name="delta_boat" parent="." instance=ExtResource( "2_824w2" )]
|
||||||
transform = Transform3D(-0.870957, 0, -0.49136, 0, 1, 0, 0.49136, 0, -0.870957, 7.46743, -1.07318, 12.6543)
|
transform = Transform3D(-0.870957, 0, -0.49136, 0, 1, 0, 0.49136, 0, -0.870957, 7.46743, -1.07318, 12.6543)
|
||||||
|
|
||||||
|
[node name="Area3D" type="Area3D" parent="delta_boat"]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0)
|
||||||
|
|
||||||
|
[node name="CollisionShape3D" type="CollisionShape3D" parent="delta_boat/Area3D"]
|
||||||
|
shape = SubResource( "SphereShape3D_08c7l" )
|
||||||
|
|
||||||
[node name="water-level" type="MeshInstance3D" parent="."]
|
[node name="water-level" type="MeshInstance3D" parent="."]
|
||||||
transform = Transform3D(20, 0, 0, 0, 1, 0, 0, 0, 20, -0.242517, -1.07318, 0.480083)
|
transform = Transform3D(20, 0, 0, 0, 1, 0, 0, 0, 20, -0.242517, -1.07318, 0.480083)
|
||||||
mesh = SubResource( "PlaneMesh_uh76x" )
|
mesh = SubResource( "PlaneMesh_uh76x" )
|
||||||
|
@ -89,5 +98,7 @@ transform = Transform3D(20, 0, 0, 0, 3, 0, 0, 0, 20, 0, -3.96834, 0)
|
||||||
visible = false
|
visible = false
|
||||||
mesh = SubResource( "BoxMesh_1ovik" )
|
mesh = SubResource( "BoxMesh_1ovik" )
|
||||||
|
|
||||||
|
[connection signal="body_entered" from="delta_boat/Area3D" to="." method="_on_area_3d_body_entered"]
|
||||||
|
[connection signal="body_exited" from="delta_boat/Area3D" to="." method="_on_area_3d_body_exited"]
|
||||||
[connection signal="body_entered" from="underwater" to="." method="_on_underwater_body_entered"]
|
[connection signal="body_entered" from="underwater" to="." method="_on_underwater_body_entered"]
|
||||||
[connection signal="body_exited" from="underwater" to="." method="_on_underwater_body_exited"]
|
[connection signal="body_exited" from="underwater" to="." method="_on_underwater_body_exited"]
|
||||||
|
|
|
@ -35,7 +35,7 @@ func _ready() -> void:
|
||||||
|
|
||||||
|
|
||||||
func _process(_delta):
|
func _process(_delta):
|
||||||
if not camera.is_current():
|
if !weakref(camera).get_ref() or not camera.is_current():
|
||||||
# If the camera we have isn't the current one, get the current camera.
|
# If the camera we have isn't the current one, get the current camera.
|
||||||
camera = get_viewport().get_camera_3d()
|
camera = get_viewport().get_camera_3d()
|
||||||
|
|
||||||
|
|
|
@ -5,53 +5,81 @@
|
||||||
[node name="character" instance=ExtResource( "1_fjis3" )]
|
[node name="character" instance=ExtResource( "1_fjis3" )]
|
||||||
|
|
||||||
[node name="Skeleton3D" parent="char_grp/rig" index="0"]
|
[node name="Skeleton3D" parent="char_grp/rig" index="0"]
|
||||||
bones/2/position = Vector3(-0.00506478, 0.466326, 0.942895)
|
bones/2/position = Vector3(-0.0168953, 0.508946, 0.0291032)
|
||||||
bones/3/rotation = Quaternion(-0.133785, -0.0316834, 0.071252, 0.987938)
|
bones/3/rotation = Quaternion(0.0770252, 0.0061187, -0.0212199, 0.996785)
|
||||||
bones/5/position = Vector3(-0.218553, 0.126083, 0.922158)
|
bones/5/position = Vector3(-0.338156, 0.447438, -0.124041)
|
||||||
bones/5/rotation = Quaternion(-0.715018, 0.0661517, 0.662421, 0.213475)
|
bones/5/rotation = Quaternion(-0.307262, -0.314094, -0.387365, 0.810484)
|
||||||
bones/6/rotation = Quaternion(-1.3178e-07, 0.0114362, 3.58596e-07, 0.999935)
|
bones/6/rotation = Quaternion(-1.33212e-07, 0.587936, 2.74967e-07, 0.808907)
|
||||||
bones/10/position = Vector3(-0.00191097, -0.0125695, 0.857793)
|
bones/10/position = Vector3(0.00813095, 0.0408708, -0.108271)
|
||||||
bones/10/rotation = Quaternion(0.00623195, 0.99891, -0.0462335, 0.00168693)
|
bones/10/rotation = Quaternion(-0.0316695, 0.99443, 0.0903084, 0.0441596)
|
||||||
bones/11/rotation = Quaternion(-0.167316, 0.020861, -0.00928351, 0.985639)
|
bones/11/rotation = Quaternion(-0.0554995, 0.082172, -0.0341149, 0.994487)
|
||||||
bones/12/rotation = Quaternion(0.006424, 0.0132741, -0.00297561, 0.999887)
|
bones/12/rotation = Quaternion(-0.00305444, 0.025317, 0.0780189, 0.996626)
|
||||||
bones/16/rotation = Quaternion(-0.656904, 0.253208, 0.332021, 0.627793)
|
bones/16/rotation = Quaternion(-0.556256, 0.383694, 0.301203, 0.672781)
|
||||||
bones/17/rotation = Quaternion(-0.509886, -0.0544441, 0.172774, 0.840953)
|
bones/17/rotation = Quaternion(-0.141952, 0.0631606, 0.424369, 0.89206)
|
||||||
bones/21/rotation = Quaternion(-0.575522, -0.37039, -0.451503, 0.572477)
|
bones/21/rotation = Quaternion(-0.545859, -0.416195, -0.418758, 0.594526)
|
||||||
bones/23/rotation = Quaternion(-0.492885, 0.0813709, -0.0822871, 0.862364)
|
bones/23/rotation = Quaternion(-0.0614123, -0.0911368, -0.507933, 0.854358)
|
||||||
bones/26/rotation = Quaternion(-0.029083, 0.00179413, -0.0257357, 0.999244)
|
bones/26/rotation = Quaternion(-0.092396, -0.012508, -0.016474, 0.995508)
|
||||||
bones/35/rotation = Quaternion(0.103596, -0.0863059, -0.0483063, 0.98969)
|
bones/35/rotation = Quaternion(0.213681, -0.169249, -0.44672, 0.852136)
|
||||||
bones/36/rotation = Quaternion(0.039159, -0.0748465, 0.26351, 0.960951)
|
bones/36/rotation = Quaternion(0.0247409, -0.037012, 0.820981, 0.569217)
|
||||||
bones/38/rotation = Quaternion(0.281259, 0.566062, -0.451518, 0.629761)
|
bones/38/rotation = Quaternion(0.453842, 0.608797, -0.453608, 0.466513)
|
||||||
bones/39/rotation = Quaternion(0.00479683, 0.989189, 0.146566, 0.000713159)
|
bones/39/rotation = Quaternion(0.00476178, 0.990816, 0.135133, 0.000459045)
|
||||||
bones/40/rotation = Quaternion(0.107401, -3.18739e-08, -0.0391236, 0.993446)
|
bones/40/rotation = Quaternion(0.296613, -3.00156e-08, -0.396533, 0.868782)
|
||||||
bones/46/rotation = Quaternion(0.214792, 0.222058, 0.00962893, 0.951032)
|
bones/46/rotation = Quaternion(0.108501, 0.138792, 0.458381, 0.871121)
|
||||||
bones/47/rotation = Quaternion(0.0335214, 0.0695326, -0.186123, 0.97949)
|
bones/47/rotation = Quaternion(0.0456323, -0.0606414, -0.827615, 0.556142)
|
||||||
bones/49/rotation = Quaternion(0.248496, -0.66888, 0.30841, 0.629073)
|
bones/49/rotation = Quaternion(0.280632, -0.521484, 0.48779, 0.641374)
|
||||||
bones/50/rotation = Quaternion(-0.00467455, 0.994189, 0.107551, 0.000154286)
|
bones/51/rotation = Quaternion(0.179271, -2.5339e-08, 0.4356, 0.882108)
|
||||||
bones/51/rotation = Quaternion(0.211355, -2.09798e-08, -0.0394617, 0.976612)
|
bones/54/position = Vector3(0.312623, 0.437755, -0.109832)
|
||||||
bones/54/position = Vector3(0.196354, 0.122889, 0.914004)
|
bones/54/rotation = Quaternion(-0.337628, 0.316336, 0.395958, 0.793194)
|
||||||
bones/54/rotation = Quaternion(-0.416081, 0.00519037, -0.872079, 0.257542)
|
bones/55/rotation = Quaternion(0.220858, -0.415893, -0.0365474, 0.88143)
|
||||||
bones/55/rotation = Quaternion(-0.179861, -0.15027, -0.0187863, 0.971965)
|
bones/58/rotation = Quaternion(-0.178058, -0.000701349, -0.0247728, 0.983708)
|
||||||
bones/96/position = Vector3(0.224384, -0.433829, 0.887285)
|
bones/61/rotation = Quaternion(-0.102877, -0.00071574, -0.0123909, 0.994617)
|
||||||
bones/96/rotation = Quaternion(-0.373285, -0.213196, -0.902139, 0.0367621)
|
bones/63/rotation = Quaternion(-0.0472496, -0.000244748, -0.00575957, 0.998866)
|
||||||
bones/97/rotation = Quaternion(9.63929e-08, -0.0209701, -1.19635e-07, 0.99978)
|
bones/66/rotation = Quaternion(-0.234863, 0.000405445, -0.0293189, 0.971586)
|
||||||
bones/101/position = Vector3(0.196354, 0.122889, 0.914004)
|
bones/69/rotation = Quaternion(-0.0621532, 0.000344386, -0.00745976, 0.998039)
|
||||||
bones/101/rotation = Quaternion(-0.416081, 0.0051903, -0.872079, 0.257542)
|
bones/71/rotation = Quaternion(-0.0202359, -0.000526936, -0.00241824, 0.999792)
|
||||||
bones/104/rotation = Quaternion(-2.77398e-07, -0.152845, -2.43311e-07, 0.98825)
|
bones/74/rotation = Quaternion(-0.118501, -0.00204265, -0.00167214, 0.99295)
|
||||||
bones/106/position = Vector3(-0.170355, 0.239115, 0.925624)
|
bones/77/rotation = Quaternion(-0.0608605, -6.15146e-05, -0.00731642, 0.998119)
|
||||||
bones/106/rotation = Quaternion(-0.7052, 0.13406, 0.68003, 0.149266)
|
bones/79/rotation = Quaternion(-0.0215469, -0.000118847, -0.0025894, 0.999765)
|
||||||
bones/109/position = Vector3(0.135571, -0.235057, 0.881648)
|
bones/82/rotation = Quaternion(-0.045812, 0.0774554, -0.0426766, 0.995028)
|
||||||
bones/109/rotation = Quaternion(-0.46927, -0.111662, -0.857984, 0.17658)
|
bones/85/rotation = Quaternion(-0.341894, -0.0505131, -0.00712847, 0.938353)
|
||||||
bones/112/position = Vector3(-0.158349, -0.451938, 0.808648)
|
bones/87/rotation = Quaternion(-0.112437, -0.0105561, -0.016501, 0.993466)
|
||||||
bones/112/rotation = Quaternion(0.509246, -0.191365, -0.838008, 0.042307)
|
bones/90/rotation = Quaternion(-0.226489, 0.0119206, 0.0152102, 0.973822)
|
||||||
bones/115/rotation = Quaternion(2.14026e-08, 0.0120989, -5.34386e-08, 0.999927)
|
bones/93/rotation = Quaternion(-0.0421871, 5.92849e-06, -0.00505668, 0.999097)
|
||||||
bones/117/position = Vector3(-0.218554, 0.126083, 0.922158)
|
bones/95/rotation = Quaternion(-0.00828159, -0.000121388, -0.000993767, 0.999965)
|
||||||
bones/117/rotation = Quaternion(-0.715018, 0.0661503, 0.662421, 0.213473)
|
bones/96/position = Vector3(0.26788, -0.0799248, -0.461465)
|
||||||
bones/118/rotation = Quaternion(-0.0306712, 0.0114382, -0.00100564, 0.999464)
|
bones/96/rotation = Quaternion(0.495633, 0.199817, 0.813215, 0.230442)
|
||||||
bones/159/position = Vector3(-0.10482, -0.243509, 0.842137)
|
bones/97/rotation = Quaternion(8.85872e-08, 0.0024306, -5.89807e-10, 0.999997)
|
||||||
bones/159/rotation = Quaternion(-0.600852, 0.0137189, 0.785812, 0.145904)
|
bones/101/position = Vector3(0.312623, 0.437755, -0.109832)
|
||||||
bones/162/position = Vector3(0.150024, 0.235589, 0.930238)
|
bones/101/rotation = Quaternion(-0.337628, 0.316336, 0.395958, 0.793194)
|
||||||
bones/162/rotation = Quaternion(-0.415601, -0.0206444, -0.886383, 0.202918)
|
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)
|
||||||
|
|
||||||
[node name="AnimationPlayer" parent="." index="1"]
|
[node name="AnimationPlayer" parent="." index="1"]
|
||||||
autoplay = "CHAR_idle_bored"
|
autoplay = "CHAR_idle_bored"
|
||||||
|
|
101
player/player.gd
101
player/player.gd
|
@ -1,6 +1,8 @@
|
||||||
extends CharacterBody3D
|
extends CharacterBody3D
|
||||||
|
|
||||||
|
|
||||||
|
signal switch_to_ship
|
||||||
|
|
||||||
enum StatePlayer {FLY = 0, SWIM = 1, WALK = 2, WALK_WATER=3}
|
enum StatePlayer {FLY = 0, SWIM = 1, WALK = 2, WALK_WATER=3}
|
||||||
|
|
||||||
# Constant
|
# Constant
|
||||||
|
@ -89,6 +91,11 @@ var max_collided_speed = 0.0
|
||||||
@onready var camera_fps:Camera3D = $camera_root/Camera3D_FPS_WALK
|
@onready var camera_fps:Camera3D = $camera_root/Camera3D_FPS_WALK
|
||||||
@onready var height_step:Vector3 = $RayCastStep.get_position() - $RayCastGround.get_position()
|
@onready var height_step:Vector3 = $RayCastStep.get_position() - $RayCastGround.get_position()
|
||||||
|
|
||||||
|
var on_ship:bool = false
|
||||||
|
var near_boat:Node3D = null
|
||||||
|
|
||||||
|
var jump_disabled:bool = false
|
||||||
|
|
||||||
|
|
||||||
func switch_state(new_state):
|
func switch_state(new_state):
|
||||||
if state_player == new_state:
|
if state_player == new_state:
|
||||||
|
@ -105,6 +112,9 @@ func switch_state(new_state):
|
||||||
camera_fps.make_current()
|
camera_fps.make_current()
|
||||||
else:
|
else:
|
||||||
camera_fps = $camera_root/Camera3D_FPS_WALK
|
camera_fps = $camera_root/Camera3D_FPS_WALK
|
||||||
|
$CollisionWalk.disabled = false
|
||||||
|
$CollisionFly.disabled = true
|
||||||
|
$CollisionSwim.disabled = true
|
||||||
StatePlayer.WALK:
|
StatePlayer.WALK:
|
||||||
print("switch camera WALK")
|
print("switch camera WALK")
|
||||||
#$carpet.hide()
|
#$carpet.hide()
|
||||||
|
@ -115,6 +125,9 @@ func switch_state(new_state):
|
||||||
camera_fps.make_current()
|
camera_fps.make_current()
|
||||||
else:
|
else:
|
||||||
camera_fps = $camera_root/Camera3D_FPS_WALK
|
camera_fps = $camera_root/Camera3D_FPS_WALK
|
||||||
|
$CollisionWalk.disabled = false
|
||||||
|
$CollisionFly.disabled = true
|
||||||
|
$CollisionSwim.disabled = true
|
||||||
StatePlayer.FLY:
|
StatePlayer.FLY:
|
||||||
print("switch camera FLY")
|
print("switch camera FLY")
|
||||||
#$carpet.show()
|
#$carpet.show()
|
||||||
|
@ -125,6 +138,9 @@ func switch_state(new_state):
|
||||||
camera_fps.make_current()
|
camera_fps.make_current()
|
||||||
else:
|
else:
|
||||||
camera_fps = $camera_root/Camera3D_FPS_FLY
|
camera_fps = $camera_root/Camera3D_FPS_FLY
|
||||||
|
$CollisionWalk.disabled = true
|
||||||
|
$CollisionFly.disabled = false
|
||||||
|
$CollisionSwim.disabled = true
|
||||||
StatePlayer.SWIM:
|
StatePlayer.SWIM:
|
||||||
print("switch camera SWIM")
|
print("switch camera SWIM")
|
||||||
#$carpet.hide()
|
#$carpet.hide()
|
||||||
|
@ -135,6 +151,9 @@ func switch_state(new_state):
|
||||||
camera_fps.make_current()
|
camera_fps.make_current()
|
||||||
else:
|
else:
|
||||||
camera_fps = $camera_root/Camera3D_FPS_SWIM
|
camera_fps = $camera_root/Camera3D_FPS_SWIM
|
||||||
|
$CollisionWalk.disabled = true
|
||||||
|
$CollisionFly.disabled = true
|
||||||
|
$CollisionSwim.disabled = false
|
||||||
|
|
||||||
|
|
||||||
func search_animation( obj:Node , root:String = "/") -> bool:
|
func search_animation( obj:Node , root:String = "/") -> bool:
|
||||||
|
@ -189,7 +208,56 @@ func _ready():
|
||||||
|
|
||||||
|
|
||||||
func _input(event):
|
func _input(event):
|
||||||
|
if !on_ship:
|
||||||
|
_input_player(event)
|
||||||
|
else:
|
||||||
|
_input_in_ship(event)
|
||||||
|
|
||||||
|
|
||||||
|
func _input_in_ship(event):
|
||||||
|
if Input.is_action_just_pressed("board_ship"):
|
||||||
|
on_ship = false
|
||||||
|
player_sit = false
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
func _input_player(event):
|
||||||
# Managed zoom (FPS or TPS)
|
# Managed zoom (FPS or TPS)
|
||||||
|
if near_boat != null and Input.is_action_just_pressed("board_ship"):
|
||||||
|
on_ship = true
|
||||||
|
player_sit = true
|
||||||
|
# emit_signal("switch_to_ship", near_boat)
|
||||||
|
# return
|
||||||
|
var ship_pos:Vector3 = near_boat.get_global_transform().origin #+ near_boat.get_position() #get_global_transform().basis # .get_position()
|
||||||
|
#var player_pos:Vector3 = get_position()
|
||||||
|
var player_pos:Vector3 = near_boat.get_global_transform().origin
|
||||||
|
#ship_pos = near_boat.global_translate
|
||||||
|
print("shi:", ship_pos)
|
||||||
|
print("pla:", player_pos)
|
||||||
|
var diff:Vector3 = player_pos - ship_pos
|
||||||
|
print ("dif:", diff )
|
||||||
|
print(get_position())
|
||||||
|
#translate(get_transform().basis. .xform(ship_pos))
|
||||||
|
#ranslate(diff)
|
||||||
|
# translate(ship_pos)
|
||||||
|
global_translate(diff)
|
||||||
|
|
||||||
|
print("res:", get_global_transform().origin)
|
||||||
|
return
|
||||||
|
if Input.is_action_just_pressed("switch_fps_tps"):
|
||||||
|
if tps:
|
||||||
|
camera_fps.rotate_x( -player_rotate_x )
|
||||||
|
player_rotate_x = 0
|
||||||
|
camera_fps.make_current()
|
||||||
|
tps = false
|
||||||
|
reconciliate_rotate_camera_player = false
|
||||||
|
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
|
||||||
|
$camera_root/horizontal_root.rotate_y( player_rotate_y - camera_rotate_y )
|
||||||
|
camera_rotate_y = player_rotate_y
|
||||||
|
else:
|
||||||
|
reconciliate_rotate_camera_player = true
|
||||||
|
tps = true
|
||||||
|
$camera_root/horizontal_root/vertical_root/Camera3D_TPS.make_current()
|
||||||
if Input.is_action_pressed("camera_zoom_in"):
|
if Input.is_action_pressed("camera_zoom_in"):
|
||||||
if tps:
|
if tps:
|
||||||
if zoom > ZOOM_MIN_Z:
|
if zoom > ZOOM_MIN_Z:
|
||||||
|
@ -272,6 +340,17 @@ func _input(event):
|
||||||
|
|
||||||
|
|
||||||
func _physics_process(delta):
|
func _physics_process(delta):
|
||||||
|
if !on_ship:
|
||||||
|
_physics_process_player(delta)
|
||||||
|
else:
|
||||||
|
_physics_process_in_ship(delta)
|
||||||
|
|
||||||
|
|
||||||
|
func _physics_process_in_ship(delta):
|
||||||
|
switch_animation(anim_sitting_ground_idle)
|
||||||
|
|
||||||
|
|
||||||
|
func _physics_process_player(delta):
|
||||||
# Add the gravity.
|
# Add the gravity.
|
||||||
if stop_move:
|
if stop_move:
|
||||||
return
|
return
|
||||||
|
@ -306,8 +385,10 @@ func _physics_process_walk(delta):
|
||||||
motion_velocity.y -= gravity * delta
|
motion_velocity.y -= gravity * delta
|
||||||
|
|
||||||
# Handle Jump.
|
# Handle Jump.
|
||||||
# if Input.is_action_just_pressed("ui_accept") and is_on_floor():
|
if !jump_disabled and Input.is_action_just_pressed("ui_accept") and is_on_floor():
|
||||||
# motion_velocity.y = JUMP_FORCE
|
motion_velocity.y = JUMP_FORCE
|
||||||
|
jump_disabled = true
|
||||||
|
$TimerJump.start()
|
||||||
|
|
||||||
# Get the input direction and handle the movement/deceleration.
|
# Get the input direction and handle the movement/deceleration.
|
||||||
if Input.is_action_pressed("ui_strafe"):
|
if Input.is_action_pressed("ui_strafe"):
|
||||||
|
@ -884,3 +965,19 @@ func enter_underwater():
|
||||||
func exit_underwater():
|
func exit_underwater():
|
||||||
# function called by Area3D (Water Object)
|
# function called by Area3D (Water Object)
|
||||||
switch_state(StatePlayer.WALK)
|
switch_state(StatePlayer.WALK)
|
||||||
|
|
||||||
|
|
||||||
|
func enter_boat(boat:Node3D):
|
||||||
|
print("enter_boat")
|
||||||
|
near_boat = boat
|
||||||
|
print(boat.name)
|
||||||
|
|
||||||
|
|
||||||
|
func exit_boat(boat:Node3D):
|
||||||
|
print("exit_boat")
|
||||||
|
if boat == near_boat:
|
||||||
|
near_boat = null
|
||||||
|
|
||||||
|
|
||||||
|
func _on_timer_jump_timeout():
|
||||||
|
jump_disabled = false
|
||||||
|
|
|
@ -31,7 +31,6 @@ script = ExtResource( "1_myhjw" )
|
||||||
|
|
||||||
[node name="CollisionFly" 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)
|
transform = Transform3D(1, 0, 0, 0, 0, -1, 0, 1, 0, 0, 0.994976, -0.258262)
|
||||||
visible = false
|
|
||||||
shape = SubResource( "CapsuleShape3D_a1omj" )
|
shape = SubResource( "CapsuleShape3D_a1omj" )
|
||||||
disabled = true
|
disabled = true
|
||||||
|
|
||||||
|
@ -43,12 +42,10 @@ disabled = true
|
||||||
|
|
||||||
[node name="CollisionWalk" type="CollisionShape3D" parent="."]
|
[node name="CollisionWalk" type="CollisionShape3D" parent="."]
|
||||||
transform = Transform3D(0.999787, 0, 0, 0, 0.589349, 0, 0, 0, 0.371542, 0, 0.836561, 0)
|
transform = Transform3D(0.999787, 0, 0, 0, 0.589349, 0, 0, 0, 0.371542, 0, 0.836561, 0)
|
||||||
visible = false
|
|
||||||
shape = SubResource( "CapsuleShape3D_w6qjk" )
|
shape = SubResource( "CapsuleShape3D_w6qjk" )
|
||||||
|
|
||||||
[node name="CollisionSwim" type="CollisionShape3D" parent="."]
|
[node name="CollisionSwim" type="CollisionShape3D" parent="."]
|
||||||
transform = Transform3D(1, 0, 0, 0, 0, -1, 0, 1, 0, 0, 0, 0)
|
transform = Transform3D(1, 0, 0, 0, 0, -1, 0, 1, 0, 0, 0, 0)
|
||||||
visible = false
|
|
||||||
shape = SubResource( "CapsuleShape3D_645as" )
|
shape = SubResource( "CapsuleShape3D_645as" )
|
||||||
disabled = true
|
disabled = true
|
||||||
|
|
||||||
|
@ -86,3 +83,9 @@ mesh = SubResource( "PlaneMesh_p36im" )
|
||||||
|
|
||||||
[node name="RayCastStep" type="RayCast3D" parent="."]
|
[node name="RayCastStep" type="RayCast3D" parent="."]
|
||||||
transform = Transform3D(1, 0, 0, 0, 0, 1, 0, -0.4, 0, 0, 0.4, 0)
|
transform = Transform3D(1, 0, 0, 0, 0, 1, 0, -0.4, 0, 0, 0.4, 0)
|
||||||
|
|
||||||
|
[node name="TimerJump" type="Timer" parent="."]
|
||||||
|
wait_time = 5.0
|
||||||
|
one_shot = true
|
||||||
|
|
||||||
|
[connection signal="timeout" from="TimerJump" to="." method="_on_timer_jump_timeout"]
|
||||||
|
|
59
player/player_ship/player_ship.gd
Normal file
59
player/player_ship/player_ship.gd
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
extends CharacterBody3D
|
||||||
|
|
||||||
|
const SPEED = 5.0
|
||||||
|
const JUMP_VELOCITY = 4.5
|
||||||
|
var tps:bool = true
|
||||||
|
var animation_object:AnimationPlayer = null
|
||||||
|
|
||||||
|
# Get the gravity from the project settings to be synced with RigidDynamicBody nodes.
|
||||||
|
var gravity = ProjectSettings.get_setting("physics/3d/default_gravity")
|
||||||
|
|
||||||
|
|
||||||
|
func _init():
|
||||||
|
tps = true
|
||||||
|
print("_init player_ship")
|
||||||
|
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
search_animation($character, "/")
|
||||||
|
$camera_root/horizontal_root/vertical_root/Camera3D_TPS.make_current()
|
||||||
|
print("_ready player_ship")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
func search_animation( obj:Node , root:String = "/") -> bool:
|
||||||
|
var ret:bool = false
|
||||||
|
for i in obj.get_children():
|
||||||
|
print("DEBUG - search_animation: " + root + String(i.get_name()))
|
||||||
|
if i.get_name() == "AnimationPlayer" or i.get_name() == "animation_player":
|
||||||
|
animation_object = i
|
||||||
|
return true
|
||||||
|
else:
|
||||||
|
ret = search_animation(i, root + String(i.get_name()) + "/" )
|
||||||
|
if ret == true:
|
||||||
|
return ret
|
||||||
|
return false
|
||||||
|
|
||||||
|
|
||||||
|
func _physics_process(delta):
|
||||||
|
return
|
||||||
|
# Add the gravity.
|
||||||
|
if not is_on_floor():
|
||||||
|
motion_velocity.y -= gravity * delta
|
||||||
|
|
||||||
|
# Handle Jump.
|
||||||
|
if Input.is_action_just_pressed("ui_accept") and is_on_floor():
|
||||||
|
motion_velocity.y = JUMP_VELOCITY
|
||||||
|
|
||||||
|
# Get the input direction and handle the movement/deceleration.
|
||||||
|
# As good practice, you should replace UI actions with custom gameplay actions.
|
||||||
|
var input_dir = Input.get_vector("ui_left", "ui_right", "ui_up", "ui_down")
|
||||||
|
var direction = (transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
|
||||||
|
if direction:
|
||||||
|
motion_velocity.x = direction.x * SPEED
|
||||||
|
motion_velocity.z = direction.z * SPEED
|
||||||
|
else:
|
||||||
|
motion_velocity.x = move_toward(motion_velocity.x, 0, SPEED)
|
||||||
|
motion_velocity.z = move_toward(motion_velocity.z, 0, SPEED)
|
||||||
|
|
||||||
|
move_and_slide()
|
36
player/player_ship/player_ship.tscn
Normal file
36
player/player_ship/player_ship.tscn
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
[gd_scene load_steps=5 format=3 uid="uid://c5b2f1o0d36aj"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://player/player_ship/player_ship.gd" id="1_16158"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://duptl2212yaxs" path="res://maps/delta_boat.tscn" id="2_bx1jl"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://cjklxedjnvc1c" path="res://player/character/character.tscn" id="3_4lkoo"]
|
||||||
|
|
||||||
|
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_llylc"]
|
||||||
|
radius = 0.638144
|
||||||
|
height = 2.57405
|
||||||
|
|
||||||
|
[node name="Node3D" type="CharacterBody3D"]
|
||||||
|
script = ExtResource( "1_16158" )
|
||||||
|
|
||||||
|
[node name="delta_boat" parent="." instance=ExtResource( "2_bx1jl" )]
|
||||||
|
transform = Transform3D(-1, 0, -1.50996e-07, 0, 1, 0, 1.50996e-07, 0, -1, 0, 0, 0)
|
||||||
|
|
||||||
|
[node name="character" parent="." instance=ExtResource( "3_4lkoo" )]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.126486, -0.179606)
|
||||||
|
|
||||||
|
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 0, -1, 0, 1, 0, 0, 0.337255, 0)
|
||||||
|
shape = SubResource( "CapsuleShape3D_llylc" )
|
||||||
|
|
||||||
|
[node name="camera_root" type="Node3D" parent="."]
|
||||||
|
|
||||||
|
[node name="horizontal_root" type="Node3D" parent="camera_root"]
|
||||||
|
transform = Transform3D(-1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 0, 0, 0)
|
||||||
|
|
||||||
|
[node name="vertical_root" type="Node3D" parent="camera_root/horizontal_root"]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.35248, 0)
|
||||||
|
|
||||||
|
[node name="Camera3D_TPS" type="Camera3D" parent="camera_root/horizontal_root/vertical_root"]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.74846e-07, 0, 2)
|
||||||
|
|
||||||
|
[node name="Camera3D_FPS" type="Camera3D" parent="camera_root"]
|
||||||
|
transform = Transform3D(-1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 0, 0.761588, 0)
|
|
@ -86,7 +86,24 @@ switch_state_player={
|
||||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":67,"physical_keycode":0,"unicode":99,"echo":false,"script":null)
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":67,"physical_keycode":0,"unicode":99,"echo":false,"script":null)
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
switch_fps_tps={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":86,"physical_keycode":0,"unicode":118,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
board_ship={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":70,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
[internationalization]
|
[internationalization]
|
||||||
|
|
||||||
locale/translations=PackedStringArray("res://locales/en.po", "res://locales/fr.po")
|
locale/translations=PackedStringArray("res://locales/en.po", "res://locales/fr.po")
|
||||||
|
|
||||||
|
[layer_names]
|
||||||
|
|
||||||
|
3d_render/layer_1="Player"
|
||||||
|
3d_render/layer_2="Walls"
|
||||||
|
3d_render/layer_3="Enemies"
|
||||||
|
3d_render/layer_4="Boat"
|
||||||
|
|
58
scenes/main/main.gd
Normal file
58
scenes/main/main.gd
Normal file
|
@ -0,0 +1,58 @@
|
||||||
|
extends Node3D
|
||||||
|
|
||||||
|
var oldobject:Node3D = null
|
||||||
|
@onready var player_ptr = $player
|
||||||
|
|
||||||
|
# Called when the node enters the scene tree for the first time.
|
||||||
|
func _ready():
|
||||||
|
$player.connect("switch_to_ship", self.switch_to_ship.bind() )
|
||||||
|
# $player_ship.set_process(false)
|
||||||
|
# $player_ship.hide()
|
||||||
|
|
||||||
|
|
||||||
|
func change_creature( new_model_path ):
|
||||||
|
var new_model = load( new_model_path )
|
||||||
|
if new_model:
|
||||||
|
new_model = new_model.instantiate()
|
||||||
|
new_model.translate($player.get_position())
|
||||||
|
if $player:
|
||||||
|
print("Remove old")
|
||||||
|
var old_model = $player
|
||||||
|
self.remove_child( old_model )
|
||||||
|
#self.animation_object = null
|
||||||
|
old_model.queue_free()
|
||||||
|
if new_model:
|
||||||
|
print("Add new")
|
||||||
|
self.add_child( new_model )
|
||||||
|
#new_model.connect( "animation_finished", self, "_on_creature_animation_finished" )
|
||||||
|
# new_model.duplicate_meshes()
|
||||||
|
|
||||||
|
func switch_to_ship(near_boat):
|
||||||
|
near_boat.hide()
|
||||||
|
oldobject = near_boat
|
||||||
|
print("GO switch_to_ship:", str(near_boat))
|
||||||
|
|
||||||
|
var new_model = load( "res://player/player_ship/player_ship.tscn" )
|
||||||
|
if new_model:
|
||||||
|
new_model = new_model.instantiate()
|
||||||
|
print("A:", near_boat.get_position())
|
||||||
|
print("B:", near_boat.get_global_transform().origin )
|
||||||
|
var newpos:Vector3 = near_boat.get_global_transform().origin
|
||||||
|
new_model.translate(newpos)
|
||||||
|
if $player:
|
||||||
|
print("Remove old")
|
||||||
|
var old_model = $player
|
||||||
|
self.remove_child( old_model )
|
||||||
|
#self.animation_object = null
|
||||||
|
old_model.queue_free()
|
||||||
|
if new_model:
|
||||||
|
print("Add new")
|
||||||
|
self.add_child( new_model )
|
||||||
|
# $player.set_process(false)
|
||||||
|
# $player.hide()
|
||||||
|
# $player_ship.show()
|
||||||
|
# $player_ship.set_process(true)
|
||||||
|
|
||||||
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
|
func _process(delta):
|
||||||
|
pass
|
|
@ -1,10 +1,12 @@
|
||||||
[gd_scene load_steps=4 format=3 uid="uid://cem7wppuuoabv"]
|
[gd_scene load_steps=5 format=3 uid="uid://cem7wppuuoabv"]
|
||||||
|
|
||||||
[ext_resource type="PackedScene" uid="uid://dwxrvijqyym70" path="res://player/player.tscn" id="1_btdsd"]
|
[ext_resource type="PackedScene" uid="uid://dwxrvijqyym70" path="res://player/player.tscn" id="1_btdsd"]
|
||||||
|
[ext_resource type="Script" path="res://scenes/main/main.gd" id="1_ld2xt"]
|
||||||
[ext_resource type="PackedScene" uid="uid://cvdmfc2hi172g" path="res://maps/basic_setup.tscn" id="2_jj4oa"]
|
[ext_resource type="PackedScene" uid="uid://cvdmfc2hi172g" path="res://maps/basic_setup.tscn" id="2_jj4oa"]
|
||||||
[ext_resource type="PackedScene" uid="uid://cdyi1a858p7em" path="res://scenes/hud/hud.tscn" id="3_5vcj4"]
|
[ext_resource type="PackedScene" uid="uid://cdyi1a858p7em" path="res://scenes/hud/hud.tscn" id="3_5vcj4"]
|
||||||
|
|
||||||
[node name="main_scene" type="Node3D"]
|
[node name="main_scene" type="Node3D"]
|
||||||
|
script = ExtResource( "1_ld2xt" )
|
||||||
|
|
||||||
[node name="player" parent="." instance=ExtResource( "1_btdsd" )]
|
[node name="player" parent="." instance=ExtResource( "1_btdsd" )]
|
||||||
transform = Transform3D(0.750872, 0, -0.660447, 0, 1, 0, 0.660447, 0, 0.750872, -3.68624, 0, -17.6199)
|
transform = Transform3D(0.750872, 0, -0.660447, 0, 1, 0, 0.660447, 0, 0.750872, -3.68624, 0, -17.6199)
|
||||||
|
|
Loading…
Reference in a new issue