Commit ec8e34b5 authored by Otto Naderer's avatar Otto Naderer

wip shooting rounds at turret pos

parent 5b907323
......@@ -57,25 +57,26 @@ func _input(ie):
if ie.type == InputEvent.MOUSE_MOTION:
var turret = get_node("Turret")
var cannon = get_node("Turret/Cannon")
#var pitch = rad2deg(camera.get_rotation().x)
#print(cannon.get_rotation())
var plus_pitch = view_sensitivity * -ie.relative_y
var plus_yaw = fmod(view_sensitivity * ie.relative_x,360)
var can_rot = cannon.get_rotation()
can_rot.z -= deg2rad(plus_pitch)
var can_elev = rad2deg(can_rot.z)
if can_elev < 7 and can_elev > -30:
cannon.set_rotation(can_rot)
#if can_elev < 7 and can_elev > -30:
cannon.set_rotation(can_rot)
#print(cannon.get_global_transform().get_rotation())
turret.rotate(Vector3(0,1,0), deg2rad(plus_yaw))
#cannon.rotate(Vector3(0,0,1), deg2rad(plus_pitch))
#print(deg2rad(plus_pitch))
#print(rad2deg(cannon.get_rotation().z))
#print(turret.get_rotation())
elif ie.type == InputEvent.MOUSE_BUTTON:
if ie.button_index == BUTTON_LEFT and ie.is_pressed():
print("LEFT CLICK")
var shot = shotscene.instance()
get_parent().add_child(shot)
#shot.set_pos(Vector3(0,0,0))
shot.set_linear_velocity(Vector3(0,0,100))
\ No newline at end of file
var shot_dir = get_node("Turret/Cannon/Aimpoint").get_global_transform().origin - get_node("Turret/Cannon").get_global_transform().origin
shot.set_transform(get_node("Turret/Cannon/Aimpoint").get_global_transform())
shot.set_linear_velocity(shot_dir.normalized() * 100.0)
#shot.set_linear_velocity(shot.get_rotation().normalized() * 10)
shot.connect("body_enter", self, "shot_hit")
func shot_hit(obj):
print ("Own shot hit obj: " + obj.get_name())
\ No newline at end of file
......@@ -14,7 +14,7 @@ extents = Vector3( 1.06913, 0.569071, 2.77569 )
_import_transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )
[node name="VehicleBody" type="VehicleBody" parent="."]
[node name="TankBody" type="VehicleBody" parent="."]
_import_transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )
input/ray_pickable = true
......@@ -33,7 +33,7 @@ body/friction = 1.0
script/script = ExtResource( 1 )
engine_force = 40
[node name="MeshInstance" type="MeshInstance" parent="VehicleBody"]
[node name="MeshInstance" type="MeshInstance" parent="TankBody"]
_import_transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )
layers = 1
......@@ -54,7 +54,7 @@ mesh/mesh = ExtResource( 2 )
mesh/skeleton = NodePath("..")
material/0 = null
[node name="VehicleWheel" type="VehicleWheel" parent="VehicleBody"]
[node name="VehicleWheel" type="VehicleWheel" parent="TankBody"]
editor/display_folded = true
_import_transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )
......@@ -70,7 +70,7 @@ suspension/max_force = 6000.0
damping/compression = 0.83
damping/relaxation = 0.88
[node name="MeshInstance" type="MeshInstance" parent="VehicleBody/VehicleWheel"]
[node name="MeshInstance" type="MeshInstance" parent="TankBody/VehicleWheel"]
_import_transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )
layers = 1
......@@ -91,7 +91,7 @@ mesh/mesh = ExtResource( 3 )
mesh/skeleton = NodePath("..")
material/0 = null
[node name="VehicleWheel1" type="VehicleWheel" parent="VehicleBody"]
[node name="VehicleWheel1" type="VehicleWheel" parent="TankBody"]
editor/display_folded = true
_import_transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )
......@@ -107,7 +107,7 @@ suspension/max_force = 6000.0
damping/compression = 0.83
damping/relaxation = 0.88
[node name="MeshInstance" type="MeshInstance" parent="VehicleBody/VehicleWheel1"]
[node name="MeshInstance" type="MeshInstance" parent="TankBody/VehicleWheel1"]
_import_transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )
transform/local = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -0.00275898, -2.38419e-07, -0.00476646 )
......@@ -129,7 +129,7 @@ mesh/mesh = ExtResource( 3 )
mesh/skeleton = NodePath("..")
material/0 = null
[node name="VehicleWheel2" type="VehicleWheel" parent="VehicleBody"]
[node name="VehicleWheel2" type="VehicleWheel" parent="TankBody"]
editor/display_folded = true
_import_transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )
......@@ -145,7 +145,7 @@ suspension/max_force = 6000.0
damping/compression = 0.83
damping/relaxation = 0.88
[node name="MeshInstance" type="MeshInstance" parent="VehicleBody/VehicleWheel2"]
[node name="MeshInstance" type="MeshInstance" parent="TankBody/VehicleWheel2"]
_import_transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )
layers = 1
......@@ -166,7 +166,7 @@ mesh/mesh = ExtResource( 3 )
mesh/skeleton = NodePath("..")
material/0 = null
[node name="VehicleWheel3" type="VehicleWheel" parent="VehicleBody"]
[node name="VehicleWheel3" type="VehicleWheel" parent="TankBody"]
editor/display_folded = true
_import_transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )
......@@ -182,7 +182,7 @@ suspension/max_force = 6000.0
damping/compression = 0.83
damping/relaxation = 0.88
[node name="MeshInstance" type="MeshInstance" parent="VehicleBody/VehicleWheel3"]
[node name="MeshInstance" type="MeshInstance" parent="TankBody/VehicleWheel3"]
_import_transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )
layers = 1
......@@ -203,7 +203,7 @@ mesh/mesh = ExtResource( 3 )
mesh/skeleton = NodePath("..")
material/0 = null
[node name="CollisionShape" type="CollisionShape" parent="VehicleBody"]
[node name="CollisionShape" type="CollisionShape" parent="TankBody"]
_import_transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )
transform/local = Transform( 0.926353, 0, 0, 0, 0.926353, 0, 0, 0, 0.926353, 0, 0, 0 )
......@@ -211,7 +211,7 @@ shape = SubResource( 1 )
trigger = false
_update_shape_index = 0
[node name="Turret" type="MeshInstance" parent="VehicleBody"]
[node name="Turret" type="MeshInstance" parent="TankBody"]
_import_transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )
transform/local = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.495483, 0 )
......@@ -233,10 +233,10 @@ mesh/mesh = ExtResource( 4 )
mesh/skeleton = NodePath("..")
material/0 = null
[node name="Cannon" type="MeshInstance" parent="VehicleBody/Turret"]
[node name="Cannon" type="MeshInstance" parent="TankBody/Turret"]
_import_transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )
transform/local = Transform( -4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, 0.083864, 0.154639, -0.0776682 )
transform/local = Transform( -4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, 0.00988415, 0.154639, -0.0776682 )
layers = 1
geometry/visible = true
geometry/material_override = null
......@@ -255,10 +255,10 @@ mesh/mesh = ExtResource( 5 )
mesh/skeleton = NodePath("..")
material/0 = null
[node name="Camera" type="InterpolatedCamera" parent="VehicleBody/Turret/Cannon"]
[node name="Camera" type="InterpolatedCamera" parent="TankBody/Turret/Cannon"]
_import_transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )
transform/local = Transform( 1.94079e-08, -0.278, 0.960581, 8.39767e-08, 0.96058, 0.278, -1, 7.52709e-08, 4.19883e-08, -0.272305, 0.527291, 0.0291164 )
transform/local = Transform( 0.999893, 0.0024913, -0.0144434, 8.61506e-08, 0.985446, 0.169983, 0.0146567, -0.169964, 0.985341, -4.13644, 0.742932, 6.99829 )
projection = 0
fov = 60.0
near = 0.1
......@@ -273,4 +273,23 @@ target = NodePath("")
speed = 1.0
enabled = false
[node name="Aimpoint" type="TestCube" parent="TankBody/Turret/Cannon"]
_import_transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )
transform/local = Transform( 0, -0.0278, 0.096058, 0, 0.096058, 0.0278, -0.1, 0, 0, -2.94812, 0.012086, 0.0291159 )
layers = 1
geometry/visible = true
geometry/material_override = null
geometry/cast_shadow = 1
geometry/receive_shadows = true
geometry/range_begin = 0.0
geometry/range_end = 0.0
geometry/extra_cull_margin = 0.0
geometry/billboard = false
geometry/billboard_y = false
geometry/depth_scale = false
geometry/visible_in_all_rooms = false
geometry/use_baked_light = false
geometry/baked_light_tex_id = 0
......@@ -2,6 +2,18 @@ extends RigidBody
var life_span = 0
func _ready():
set_contact_monitor(true)
set_max_contacts_reported(5)
set_fixed_process(true)
connect("body_enter", self, "on_hit")
func _fixed_process(delta):
life_span += delta
print(life_span)
\ No newline at end of file
if life_span > 5:
print("removed shot")
remove_and_skip()
func on_hit(other):
# cannot remove node right here as this would break exec
life_span = 5
\ No newline at end of file
[gd_scene load_steps=3 format=1]
[gd_scene load_steps=4 format=1]
[ext_resource path="res://tround.msh" type="Mesh" id=1]
[ext_resource path="res://tank-round.gd" type="Script" id=1]
[ext_resource path="res://tround.msh" type="Mesh" id=2]
[sub_resource type="CapsuleShape" id=1]
radius = 0.0883809
height = 0.213535
radius = 0.0575807
height = 0.184025
[node name="RigidBody" type="RigidBody"]
......@@ -34,6 +35,7 @@ velocity/linear = Vector3( 0, 0, 0 )
velocity/angular = Vector3( 0, 0, 0 )
damp_override/linear = -1.0
damp_override/angular = -1.0
script/script = ExtResource( 1 )
[node name="MeshInstance" type="MeshInstance" parent="."]
......@@ -52,7 +54,7 @@ geometry/depth_scale = false
geometry/visible_in_all_rooms = false
geometry/use_baked_light = false
geometry/baked_light_tex_id = 0
mesh/mesh = ExtResource( 1 )
mesh/mesh = ExtResource( 2 )
mesh/skeleton = NodePath("..")
material/0 = null
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment