-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProjectile.gd
34 lines (27 loc) · 988 Bytes
/
Projectile.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
33
34
extends Area
# class member variables go here, for example:
# var a = 2
# var b = "textvar"
const FIRE_GROUP = "FireElemental"
const WATER_GROUP = "WaterElemental"
const SPEED = 20
var damage = 20
var my_group
func _ready():
yield(get_tree().create_timer(10), "timeout")
queue_free()
func _physics_process(delta):
translate(delta * Vector3(0, 0, -SPEED))
func shoot_at(from_position, to_position, from_group):
my_group = from_group
if from_group == FIRE_GROUP:
$Particles.process_material.color_ramp = preload("res://gradient_projectile_fire.tres")
else:
$Particles.process_material.color_ramp = preload("res://gradient_projectile_water.tres")
look_at_from_position(from_position, to_position, Vector3(0, 1, 0))
func _on_Projectile_body_entered(body):
if ((body.is_in_group(FIRE_GROUP) and my_group == WATER_GROUP) or (body.is_in_group(WATER_GROUP) and my_group == FIRE_GROUP)):
body.takeDamage(damage)
queue_free()
if(body.is_in_group("Rock")):
queue_free()