37 lines
938 B
GDScript3
37 lines
938 B
GDScript3
extends KinematicBody2D
|
|
class_name Bullet
|
|
|
|
|
|
# Declare member variables here. Examples:
|
|
# var a = 2
|
|
# var b = "text"
|
|
var velocity = Vector2.ZERO
|
|
const GRAVITY = 0.1
|
|
|
|
# Called when the node enters the scene tree for the first time.
|
|
func _ready():
|
|
$beamtrail.emitting = Global.beamtrail
|
|
$beamtrail.visible = Global.beamtrail
|
|
$beam.visible = not Global.beamtrail
|
|
#velocity.y = -4
|
|
#velocity.x = rand_range(-10,10)
|
|
pass
|
|
|
|
func _physics_process(delta):
|
|
velocity.y += GRAVITY
|
|
var collide = move_and_collide(velocity)
|
|
if collide != null:
|
|
$CollisionShape2D.disabled = true
|
|
$beamtrail.emitting = false
|
|
$beam.visible = false
|
|
$delTimer.wait_time = $beamtrail.lifetime
|
|
$delTimer.start()
|
|
#print(collide.collider)
|
|
#if collide.collider.get_collision_layer_bit(2):
|
|
if collide.collider.is_in_group("prey"):
|
|
collide.collider.shrink()
|
|
collide.collider.set_collision_mask_bit(3,false)
|
|
|
|
|
|
func _on_delTimer_timeout():
|
|
queue_free()
|