-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathenemy.gd
32 lines (25 loc) · 897 Bytes
/
enemy.gd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
extends CharacterBody3D
const SPEED = 5.0
const JUMP_VELOCITY = 4.5
# Get the gravity from the project settings to be synced with RigidBody nodes.
var gravity = ProjectSettings.get_setting("physics/3d/default_gravity")
var boom_force = Vector3(0,0,0)
func _physics_process(delta):
# Add the gravity.
if not is_on_floor():
velocity.y -= gravity * delta
var input_dir = Vector3(0,0,0)
var direction = (transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
if direction:
velocity.x = direction.x * SPEED
velocity.z = direction.z * SPEED
else:
velocity.x = move_toward(velocity.x, 0, SPEED)
velocity.z = move_toward(velocity.z, 0, SPEED)
velocity = velocity + boom_force
boom_force = Vector3(0,0,0)
move_and_slide()
#
func hit_by_hammer(source, force):
print("Heres the loc : ", source)
boom_force = (source - global_transform.origin).normalized() * force