Update gun scene to point at a mob enemy
This commit is contained in:
parent
f4f418bcc1
commit
2e93fd8c33
|
@ -36,3 +36,12 @@ position = Vector2(1349, 521)
|
|||
position = Vector2(1492, 530)
|
||||
|
||||
[node name="Mob" parent="." instance=ExtResource("3_4vicn")]
|
||||
|
||||
[node name="Mob2" parent="." instance=ExtResource("3_4vicn")]
|
||||
position = Vector2(113, 567)
|
||||
|
||||
[node name="Mob3" parent="." instance=ExtResource("3_4vicn")]
|
||||
position = Vector2(1635, 60)
|
||||
|
||||
[node name="Mob4" parent="." instance=ExtResource("3_4vicn")]
|
||||
position = Vector2(98, 184)
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
extends Area2D
|
||||
|
||||
|
||||
func _physics_process(delta):
|
||||
var enemies_in_range = get_overlapping_bodies()
|
||||
if enemies_in_range.size() > 0:
|
||||
var target_enemy = enemies_in_range.front()
|
||||
#var target_enemy = enemies_in_range[0]
|
||||
look_at(target_enemy.global_position)
|
6
gun.tscn
6
gun.tscn
|
@ -1,11 +1,15 @@
|
|||
[gd_scene load_steps=3 format=3 uid="uid://c30f23qbcla64"]
|
||||
[gd_scene load_steps=4 format=3 uid="uid://c30f23qbcla64"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://cswb5do8rrj7q" path="res://pistol/pistol.png" id="1_vcr1c"]
|
||||
[ext_resource type="Script" path="res://gun.gd" id="1_xoy1y"]
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_4brg3"]
|
||||
radius = 570.001
|
||||
|
||||
[node name="Gun" type="Area2D"]
|
||||
collision_layer = 0
|
||||
collision_mask = 2
|
||||
script = ExtResource("1_xoy1y")
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
shape = SubResource("CircleShape2D_4brg3")
|
||||
|
|
Loading…
Reference in New Issue