sheep attacc
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
extends CharacterBody3D
|
||||
|
||||
signal attack
|
||||
|
||||
const SPEED = 3.0
|
||||
const JUMP_VELOCITY = 2.5
|
||||
|
||||
@@ -24,3 +26,12 @@ func _physics_process(delta):
|
||||
velocity.z = move_toward(velocity.z, 0, SPEED)
|
||||
|
||||
move_and_slide()
|
||||
|
||||
func _process(delta):
|
||||
if Input.is_action_just_pressed("bell"):
|
||||
print("bell")
|
||||
var enemy = get_parent().find_child("Wolf")
|
||||
print(enemy)
|
||||
attack.emit(enemy.global_transform.origin)
|
||||
elif Input.is_action_just_pressed("yell"):
|
||||
print("yell")
|
||||
|
||||
@@ -1,8 +1,19 @@
|
||||
extends CharacterBody3D
|
||||
|
||||
const ATTACK_IMPULSE = 40
|
||||
const FRICTION = 1
|
||||
|
||||
func _physics_process(delta):
|
||||
# Add the gravity.
|
||||
if not is_on_floor():
|
||||
velocity += get_gravity() * delta
|
||||
velocity.x = move_toward(velocity.x, 0, FRICTION)
|
||||
velocity.z = move_toward(velocity.z, 0, FRICTION)
|
||||
|
||||
move_and_slide()
|
||||
|
||||
func _on_player_attack(enemy_position: Vector3):
|
||||
print("atakku", enemy_position)
|
||||
var direction = (enemy_position - self.global_position).normalized()
|
||||
look_at(direction * Vector3(1, 2, 1), Vector3.UP)
|
||||
velocity += direction * ATTACK_IMPULSE
|
||||
|
||||
Reference in New Issue
Block a user