Skip to content

Commit ebd93a1

Browse files
committed
chore: sync mob code with tutorial part 10
1 parent 743b788 commit ebd93a1

File tree

4 files changed

+19
-18
lines changed

4 files changed

+19
-18
lines changed

3d-project-completed/lessons_reference/video_16/mob/bat/bat_model.gd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@ extends Node3D
22

33
@onready var animation_tree = %AnimationTree
44

5+
56
func hurt():
67
animation_tree.set("parameters/OneShot/request", true)

3d-project-completed/lessons_reference/video_16/mob/bat/bat_model.tscn

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -197,19 +197,19 @@ node_connections = [&"OneShot", 0, &"Idle", &"OneShot", 1, &"Hurt", &"output", 0
197197
script = ExtResource("1_ppjak")
198198

199199
[node name="Skeleton3D" parent="Armature" index="0"]
200-
bones/0/position = Vector3(0, 0.0236, 0)
201-
bones/1/rotation = Quaternion(0.185436, -0.00744002, -0.6376, 0.74768)
202-
bones/2/rotation = Quaternion(0.177649, 0.0781321, 0.394811, 0.898031)
203-
bones/3/rotation = Quaternion(0.138328, 0.105002, 0.361888, 0.915902)
204-
bones/4/rotation = Quaternion(0.185436, 0.00744002, 0.6376, 0.74768)
205-
bones/5/rotation = Quaternion(0.177649, -0.0781321, -0.394811, 0.898031)
206-
bones/6/rotation = Quaternion(0.138328, -0.105002, -0.361888, 0.915902)
200+
bones/0/position = Vector3(0, -0.0223505, 0)
201+
bones/1/rotation = Quaternion(-0.0584059, 0.209811, -0.6589, 0.720013)
202+
bones/2/rotation = Quaternion(-0.169099, -0.0457482, 0.256938, 0.950419)
203+
bones/3/rotation = Quaternion(-0.108905, 0.0231328, 0.220387, 0.969038)
204+
bones/4/rotation = Quaternion(-0.0584059, -0.209811, 0.6589, 0.720013)
205+
bones/5/rotation = Quaternion(-0.169099, 0.0457482, -0.256938, 0.950419)
206+
bones/6/rotation = Quaternion(-0.108905, -0.0231328, -0.220387, 0.969038)
207207
bones/7/position = Vector3(0.130992, -0.227392, -0.0878515)
208208
bones/7/rotation = Quaternion(0.261968, 0.0834552, 0.265751, 0.924005)
209-
bones/8/rotation = Quaternion(3.94755e-08, 0.65414, 0.756373, 2.47107e-08)
209+
bones/8/rotation = Quaternion(3.83607e-08, 0.634168, 0.773195, 2.38925e-08)
210210
bones/10/position = Vector3(-0.130992, -0.227392, -0.0878515)
211211
bones/10/rotation = Quaternion(0.261968, -0.0834552, -0.265751, 0.924005)
212-
bones/11/rotation = Quaternion(2.44109e-08, 0.654141, 0.756373, 3.46799e-08)
212+
bones/11/rotation = Quaternion(2.89336e-08, 0.634168, 0.773195, 3.73251e-08)
213213

214214
[node name="bat" parent="Armature/Skeleton3D" index="0"]
215215
surface_material_override/0 = ExtResource("3_uqgpt")

3d-project-completed/lessons_reference/video_16/mob/mob.gd

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ signal died
55
var speed = randf_range(2.0, 4.0)
66
var health = 3
77

8-
@onready var player = get_node("/root/Game/Player")
98
@onready var bat_model = %bat_model
9+
@onready var timer = %Timer
10+
11+
@onready var player = get_node("/root/Game/Player")
1012

1113
@onready var hurt_sound = %HurtSound
1214
@onready var ko_sound = %KOSound
@@ -33,16 +35,14 @@ func take_damage():
3335
ko_sound.play()
3436

3537
set_physics_process(false)
36-
3738
gravity_scale = 1.0
38-
39-
var direction_back = player.global_position.direction_to(global_position)
39+
var direction = player.global_position.direction_to(global_position)
4040
var random_upward_force = Vector3.UP * randf() * 5.0
41-
apply_central_impulse(direction_back.rotated(Vector3.UP, randf_range(-0.2, 0.2)) * 10.0 + random_upward_force)
41+
apply_central_impulse(direction.rotated(Vector3.UP, randf_range(-0.2, 0.2)) * 10.0 + random_upward_force)
4242

43-
%DeathTimer.start()
43+
timer.start()
4444

4545

46-
func _on_death_timer_timeout():
46+
func _on_timer_timeout():
4747
died.emit()
4848
queue_free()

3d-project-completed/lessons_reference/video_16/mob/mob.tscn

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ unique_name_in_owner = true
1818
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
1919
shape = SubResource("SphereShape3D_gkbwe")
2020

21-
[node name="DeathTimer" type="Timer" parent="."]
21+
[node name="Timer" type="Timer" parent="."]
2222
unique_name_in_owner = true
2323
one_shot = true
2424

@@ -33,4 +33,4 @@ unique_name_in_owner = true
3333
stream = ExtResource("4_qnk8k")
3434
max_db = -10.0
3535

36-
[connection signal="timeout" from="DeathTimer" to="." method="_on_death_timer_timeout"]
36+
[connection signal="timeout" from="Timer" to="." method="_on_timer_timeout"]

0 commit comments

Comments
 (0)