bullet layer and such, dont collide bullets with other bullets

This commit is contained in:
Robin Hübner 2017-08-11 21:59:26 +02:00
parent 53432b8552
commit efbcd5cf22
9 changed files with 13 additions and 11 deletions

View File

@ -15,7 +15,7 @@ input/pickable = false
shapes/0/shape = SubResource( 1 ) shapes/0/shape = SubResource( 1 )
shapes/0/transform = Matrix32( 1, 0, 0, 1, -0.17482, 1.87222 ) shapes/0/transform = Matrix32( 1, 0, 0, 1, -0.17482, 1.87222 )
shapes/0/trigger = false shapes/0/trigger = false
collision/layers = 1 collision/layers = 3
collision/mask = 1 collision/mask = 1
collision/margin = 0.08 collision/margin = 0.08
script/script = ExtResource( 1 ) script/script = ExtResource( 1 )

View File

@ -10,7 +10,7 @@ func _ready():
func fire(delta, vel, dir, speed): func fire(delta, vel, dir, speed):
velocity = (vel.length() * dir + (dir * speed * delta)) velocity = (vel.length() * dir + (dir * speed * delta))
sprite.rotate(dir.angle()) sprite.set_rot(dir.angle())
func type(): func type():
return "Bullet" return "Bullet"

View File

@ -11,11 +11,12 @@ extents = Vector2( 0.99762, 3.98857 )
[node name="Bullet" type="KinematicBody2D"] [node name="Bullet" type="KinematicBody2D"]
transform/rot = 180.0 transform/rot = 180.0
transform/scale = Vector2( 2, 2 )
input/pickable = false input/pickable = false
shapes/0/shape = SubResource( 1 ) shapes/0/shape = SubResource( 1 )
shapes/0/transform = Matrix32( 1, 0, 0, 1, 0, 0 ) shapes/0/transform = Matrix32( 1, 0, 0, 1, 0, 0 )
shapes/0/trigger = false shapes/0/trigger = false
collision/layers = 1 collision/layers = 2
collision/mask = 1 collision/mask = 1
collision/margin = 0.08 collision/margin = 0.08
script/script = ExtResource( 1 ) script/script = ExtResource( 1 )

View File

@ -8,7 +8,7 @@
transform/scale = Vector2( 2, 2 ) transform/scale = Vector2( 2, 2 )
input/pickable = false input/pickable = false
collision/layers = 1 collision/layers = 3
collision/mask = 1 collision/mask = 1
collision/margin = 0.08 collision/margin = 0.08
script/script = ExtResource( 1 ) script/script = ExtResource( 1 )

5
Gun.gd
View File

@ -4,7 +4,8 @@ var Bullet = load("res://Bullet.tscn")
var gun_cooldown = 0 var gun_cooldown = 0
var gun_delay = 0.1125 var gun_delay = 0.1125
var gun_spread_max = deg2rad(1) # degrees max var gun_spread_max = deg2rad(4) # degrees max
var gun_bullet_speed = 384
func _ready(): func _ready():
set_fixed_process(true) set_fixed_process(true)
@ -19,5 +20,5 @@ func fire(delta, vel, dir):
new_bullet.set_pos(gun_pos + vel) new_bullet.set_pos(gun_pos + vel)
get_tree().get_root().add_child(new_bullet) get_tree().get_root().add_child(new_bullet)
var rot = rand_range(-gun_spread_max, gun_spread_max) var rot = rand_range(-gun_spread_max, gun_spread_max)
new_bullet.fire(delta, vel, dir.rotated(rot), 512) new_bullet.fire(delta, vel, dir.rotated(rot), gun_bullet_speed)
gun_cooldown += gun_delay gun_cooldown += gun_delay

View File

@ -10,7 +10,7 @@
transform/scale = Vector2( 2, 2 ) transform/scale = Vector2( 2, 2 )
input/pickable = false input/pickable = false
collision/layers = 1 collision/layers = 3
collision/mask = 1 collision/mask = 1
collision/margin = 0.08 collision/margin = 0.08
script/script = ExtResource( 1 ) script/script = ExtResource( 1 )

View File

@ -6,7 +6,7 @@
[node name="PowerStation" type="KinematicBody2D"] [node name="PowerStation" type="KinematicBody2D"]
input/pickable = false input/pickable = false
collision/layers = 1 collision/layers = 3
collision/mask = 1 collision/mask = 1
collision/margin = 0.08 collision/margin = 0.08
script/script = ExtResource( 1 ) script/script = ExtResource( 1 )

BIN
raw/simple_bullet.ase (Stored with Git LFS)

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 110 B

After

Width:  |  Height:  |  Size: 138 B