Bullets now check for when they collide with a tank
This commit is contained in:
parent
98da26637d
commit
bc16fd0513
4 changed files with 15 additions and 5 deletions
|
@ -12,10 +12,10 @@ albedo_color = Color( 1, 0, 0, 1 )
|
|||
[node name="AITank00" type="KinematicBody"]
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[node name="CollisionShape" type="CollisionShape" parent="."]
|
||||
[node name="CollisionShape" type="CollisionShape" parent="." groups=["tank"]]
|
||||
shape = SubResource( 1 )
|
||||
|
||||
[node name="Tank" type="MeshInstance" parent="CollisionShape"]
|
||||
[node name="Tank" type="MeshInstance" parent="CollisionShape" groups=["tank"]]
|
||||
mesh = SubResource( 2 )
|
||||
skeleton = NodePath("../..")
|
||||
material/0 = SubResource( 3 )
|
||||
|
|
|
@ -13,6 +13,16 @@ func _physics_process(delta):
|
|||
look_at(transform.origin + velocity.normalized(), Vector3.UP)
|
||||
transform.origin += velocity * delta
|
||||
|
||||
for body in get_overlapping_bodies(): ### HERE IS WHERE THE BULLET CHECKS FOR TANK COLLISIONS
|
||||
if get_overlapping_bodies().has(get_parent().get_node("PlayerTank")):
|
||||
print ("Found Player Tank")
|
||||
self.queue_free()
|
||||
body.queue_free()
|
||||
if get_overlapping_bodies().has(get_parent().get_node("AITank00")):
|
||||
print ("Found AI Tank")
|
||||
self.queue_free()
|
||||
body.queue_free()
|
||||
|
||||
|
||||
func _on_Shell_body_entered(body):
|
||||
emit_signal("exploded", transform.origin)
|
||||
|
|
|
@ -15,5 +15,5 @@ transform = Transform( 0.200224, 0, 0, 0, 0.200224, 0, 0, 0, 0.200224, 0, 0, 0 )
|
|||
mesh = SubResource( 2 )
|
||||
material/0 = null
|
||||
|
||||
[node name="CollisionShape" type="CollisionShape" parent="."]
|
||||
[node name="CollisionShape" type="CollisionShape" parent="." groups=["bullet"]]
|
||||
shape = SubResource( 1 )
|
||||
|
|
|
@ -15,10 +15,10 @@ script = ExtResource( 1 )
|
|||
[node name="Camera" type="Camera" parent="."]
|
||||
transform = Transform( 1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0, 20.7405, -7.28392e-07 )
|
||||
|
||||
[node name="CollisionShape" type="CollisionShape" parent="."]
|
||||
[node name="CollisionShape" type="CollisionShape" parent="." groups=["tank"]]
|
||||
shape = SubResource( 1 )
|
||||
|
||||
[node name="Tank" type="MeshInstance" parent="CollisionShape"]
|
||||
[node name="Tank" type="MeshInstance" parent="CollisionShape" groups=["tank"]]
|
||||
mesh = SubResource( 2 )
|
||||
skeleton = NodePath("../..")
|
||||
material/0 = SubResource( 3 )
|
||||
|
|
Loading…
Reference in a new issue