Added WIP projectile

This commit is contained in:
Paul Black 2022-03-03 19:29:02 -07:00
parent 07daa03e63
commit d2ff6f8d25
7 changed files with 88 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 KiB

View file

@ -0,0 +1,35 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/Tank Blaster Splash.png-a9101407a1150afc7a1e50a35bebcaac.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://2D Art/Splash Screen/Tank Blaster Splash.png"
dest_files=[ "res://.import/Tank Blaster Splash.png-a9101407a1150afc7a1e50a35bebcaac.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
process/normal_map_invert_y=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

19
Objects/Bullet/Bullet.gd Normal file
View file

@ -0,0 +1,19 @@
extends Area
signal exploded
export var muzzle_velocity = 25
export var g = Vector3.DOWN * 20
var velocity = Vector3.ZERO
func _physics_process(delta):
# velocity += g * delta # Uncomment this for bullet gravity
look_at(transform.origin + velocity.normalized(), Vector3.UP)
transform.origin += velocity * delta
func _on_Shell_body_entered(body):
emit_signal("exploded", transform.origin)
queue_free()

View file

@ -0,0 +1,19 @@
[gd_scene load_steps=4 format=2]
[ext_resource path="res://Objects/Bullet/Bullet.gd" type="Script" id=1]
[sub_resource type="SphereMesh" id=2]
[sub_resource type="BoxShape" id=1]
extents = Vector3( 0.20228, 0.203418, 0.196524 )
[node name="Bullet" type="Area"]
script = ExtResource( 1 )
[node name="MeshInstance" type="MeshInstance" parent="."]
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="."]
shape = SubResource( 1 )

View file

@ -1,5 +1,6 @@
extends KinematicBody
export (PackedScene) var Bullet = preload("res://Objects/Bullet/Bullet.tscn")
onready var camera = get_node("Camera")
var rayOrigin = Vector3()
var rayEnd = Vector3()
@ -18,6 +19,11 @@ func _physics_process(delta):
direction.z += 1
if Input.is_action_pressed("move_forward"):
direction.z -= 1
if Input.is_action_just_pressed("shoot"):
var b = Bullet.instance()
owner.add_child(b)
b.transform = $BulletGenerator.global_transform
b.velocity = -b.transform.basis.z * b.muzzle_velocity
var space_state = get_world().direct_space_state
var mouse_position = get_viewport().get_mouse_position()

View file

@ -23,3 +23,6 @@ transform = Transform( 1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0, 20.7
[node name="Tank" type="MeshInstance" parent="KinematicBody"]
mesh = SubResource( 2 )
material/0 = SubResource( 3 )
[node name="BulletGenerator" type="Position3D" parent="KinematicBody"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 1.6976, 0.375606, 0.0906463 )

View file

@ -12,6 +12,7 @@ config_version=4
config/name="Tank Blaster"
run/main_scene="res://Levels/Level01.tscn"
boot_splash/image="res://2D Art/Splash Screen/Tank Blaster Splash.png"
config/icon="res://icon.png"
[display]
@ -42,6 +43,11 @@ move_forward={
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":87,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
]
}
shoot={
"deadzone": 0.5,
"events": [ Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"button_mask":0,"position":Vector2( 0, 0 ),"global_position":Vector2( 0, 0 ),"factor":1.0,"button_index":1,"pressed":false,"doubleclick":false,"script":null)
]
}
[physics]