sheep attacc
This commit is contained in:
@@ -49,3 +49,13 @@ ui_down={
|
||||
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":83,"key_label":0,"unicode":115,"location":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
yell={
|
||||
"deadzone": 0.2,
|
||||
"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":1,"position":Vector2(353, 18),"global_position":Vector2(362, 66),"factor":1.0,"button_index":1,"canceled":false,"pressed":true,"double_click":false,"script":null)
|
||||
]
|
||||
}
|
||||
bell={
|
||||
"deadzone": 0.2,
|
||||
"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":2,"position":Vector2(279, 21),"global_position":Vector2(288, 69),"factor":1.0,"button_index":2,"canceled":false,"pressed":true,"double_click":false,"script":null)
|
||||
]
|
||||
}
|
||||
|
||||
@@ -26,3 +26,5 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.713965, -7.41454)
|
||||
|
||||
[node name="Wolf" parent="." instance=ExtResource("5_iywne")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -5.11468, 1.36518, -4.14155)
|
||||
|
||||
[connection signal="attack" from="Player" to="Sheep" method="_on_player_attack"]
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
[ext_resource type="ArrayMesh" uid="uid://eqjkgu2h3c5l" path="res://assets/wolf/Wolf.obj" id="1_xsq4n"]
|
||||
|
||||
[sub_resource type="BoxShape3D" id="BoxShape3D_xsq4n"]
|
||||
size = Vector3(1, 1, 1.44244)
|
||||
size = Vector3(0.289169, 1, 1.44244)
|
||||
|
||||
[node name="Wolf" type="CharacterBody3D"]
|
||||
script = ExtResource("1_jrowp")
|
||||
@@ -14,5 +14,5 @@ transform = Transform3D(0.0064462, 0, 0, 0, 0.0064462, 0, 0, 0, 0.0064462, 0, -0
|
||||
mesh = ExtResource("1_xsq4n")
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.0223495, -0.00924683)
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.00136566, -0.0223495, -0.00924683)
|
||||
shape = SubResource("BoxShape3D_xsq4n")
|
||||
|
||||
@@ -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