Initial Commit
This commit is contained in:
commit
48a5e71e00
1136 changed files with 64347 additions and 0 deletions
32
ChatAvatars/CatSlimes/avatar_states/move.gd
Normal file
32
ChatAvatars/CatSlimes/avatar_states/move.gd
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
extends ChatterState
|
||||
class_name MoveState
|
||||
|
||||
@export var move_speed := 60.0
|
||||
|
||||
var move_direction: Vector2 = Vector2.ZERO
|
||||
var wander_time: float = 3.0
|
||||
|
||||
func randomize_wander():
|
||||
move_direction = Vector2(randf_range(-1,1), 0).normalized()
|
||||
wander_time = randf_range(1,6)
|
||||
|
||||
func _enter() -> void:
|
||||
randomize_wander()
|
||||
|
||||
func _exit() -> void:
|
||||
pass
|
||||
|
||||
func _update(delta: float) -> void:
|
||||
if wander_time > 0:
|
||||
wander_time -= delta
|
||||
else:
|
||||
if randf() > 0.5:
|
||||
transitioned.emit(self, "idle")
|
||||
else:
|
||||
randomize_wander()
|
||||
|
||||
func _physics_update(_delta: float) -> void:
|
||||
if chatter:
|
||||
if chatter.is_on_wall():
|
||||
move_direction = -move_direction
|
||||
chatter.velocity = move_direction * move_speed
|
||||
Loading…
Add table
Add a link
Reference in a new issue