@@ -20,61 +20,52 @@ pub struct Mob {
20
20
#[ godot_api]
21
21
impl ICharacterBody3D for Mob {
22
22
fn physics_process ( & mut self , _delta : f64 ) {
23
- // move_and_slide()
24
23
self . base_mut ( ) . move_and_slide ( ) ;
25
24
}
26
25
}
27
26
#[ godot_api]
28
27
impl Mob {
29
28
#[ func]
30
29
pub fn initialize ( & mut self , start_position : Vector3 , player_position : Vector3 ) {
31
- // look_at_from_position(start_position, player_position, Vector3.UP)
32
30
self . base_mut ( )
33
31
. look_at_from_position ( start_position, player_position) ;
34
32
35
- // rotate_y(randf_range(-PI / 4, PI / 4))
36
33
self . base_mut ( )
37
34
. rotate_y ( rand:: rng ( ) . random_range ( -PI / 4.0 ..PI / 4.0 ) ) ;
38
35
39
- // var random_speed = randf_range(min_speed, max_speed)
40
36
let random_speed = rand:: rng ( ) . random_range ( self . min_speed ..self . max_speed ) ;
41
37
42
38
// We calculate a forward velocity first, which represents the speed.
43
- // velocity = Vector3.FORWARD * random_speed
44
39
self . base_mut ( )
45
40
. set_velocity ( Vector3 :: FORWARD * random_speed) ;
46
41
47
42
let rotation = self . base ( ) . get_rotation ( ) ;
48
43
let velocity = self . base ( ) . get_velocity ( ) ;
49
44
50
45
// We then rotate the vector based on the mob's Y rotation to move in the direction it's looking.
51
- // velocity = velocity.rotated(Vector3.UP, rotation.y)
52
46
self . base_mut ( )
53
47
. set_velocity ( velocity. rotated ( Vector3 :: UP , rotation. y ) ) ;
54
48
55
- // $AnimationPlayer.speed_scale = random_speed / min_speed
56
49
let animation_speed = rand:: rng ( ) . random_range ( 1.0 ..6.0 ) ;
50
+
57
51
self . base ( )
58
52
. get_node_as :: < AnimationPlayer > ( "AnimationPlayer" )
59
53
. set_speed_scale ( animation_speed as f32 )
60
54
}
55
+
61
56
// Emitted when the player jumped on the mob.
62
- // signal squashed
63
57
#[ signal]
64
58
pub fn squashed ( ) ;
65
59
66
60
#[ func]
67
61
pub fn squash ( & mut self ) {
68
- // squashed.emit()
69
62
self . signals ( ) . squashed ( ) . emit ( ) ;
70
63
71
- // queue_free()
72
64
self . base_mut ( ) . queue_free ( ) ;
73
65
}
74
66
75
67
#[ func]
76
68
fn on_visible_on_screen_notifier_3d_screen_exited ( & mut self ) {
77
- // queue_free()
78
69
self . base_mut ( ) . queue_free ( ) ;
79
70
}
80
71
}
0 commit comments