This commit is contained in:
Leon Palluch 2020-02-01 16:54:58 +01:00
commit fffc3d0355
6 changed files with 52 additions and 14 deletions

View File

@ -66,6 +66,7 @@ collide_with_areas = true
collide_with_bodies = false collide_with_bodies = false
[node name="Torso" parent="." instance=ExtResource( 1 )] [node name="Torso" parent="." instance=ExtResource( 1 )]
[connection signal="pressed" from="GUI/HBoxC/VBoxC/Start" to="." method="_on_Button2_pressed"]
[editable path="Torso"] [editable path="Torso"]

View File

@ -78,8 +78,14 @@ func _input(event):
if _viewport.get_viewport().get_mouse_position().x >= 0: if _viewport.get_viewport().get_mouse_position().x >= 0:
if event is InputEventMouseButton: if event is InputEventMouseButton:
if event.pressed: if event.pressed:
_prev_mouse_pos = event.position if event.button_index == BUTTON_WHEEL_UP:
_viewRot = true _attachment_point.get_node("Limb").rotate_z(0.1)
elif event.button_index == BUTTON_WHEEL_DOWN:
_attachment_point.get_node("Limb").rotate_z(-0.1)
else:
print("Mouse Click at: ", event.position)
_prev_mouse_pos = event.position
_viewRot = true
else: else:
_viewRot = false _viewRot = false

View File

@ -15,7 +15,7 @@ func action():
func push(body): func push(body):
# We multiply by 0.1 because we only want it to spin slightly, it should mostly go up # We multiply by 0.1 because we only want it to spin slightly, it should mostly go up
base.apply_impulse(transform.basis.xform(touch_area.global_transform.origin) * 0.1, base.transform.basis.y * 5.0) base.apply_impulse(transform.basis.xform(touch_area.global_transform.origin - global_transform.origin) * 0.1, base.transform.basis.y * 5.0)
# Called every frame. 'delta' is the elapsed time since the previous frame. # Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta: float) -> void: #func _process(delta: float) -> void:

View File

@ -1,25 +1,32 @@
[gd_scene load_steps=5 format=2] [gd_scene load_steps=6 format=2]
[ext_resource path="res://BodyParts/BodyBase/BodyBase.gd" type="Script" id=1] [ext_resource path="res://BodyParts/BodyBase/BodyBase.gd" type="Script" id=1]
[ext_resource path="res://BodyParts/BodyBase/AttachmentPoint.tscn" type="PackedScene" id=2] [ext_resource path="res://BodyParts/BodyBase/AttachmentPoint.tscn" type="PackedScene" id=2]
[ext_resource path="res://3D Input/Torso.glb" type="PackedScene" id=3]
[sub_resource type="CapsuleMesh" id=1] [sub_resource type="CapsuleMesh" id=1]
[sub_resource type="CapsuleShape" id=1] [sub_resource type="CapsuleShape" id=2]
[node name="Torso" type="RigidBody"] [node name="Torso" type="RigidBody" groups=[
"Player",
]]
script = ExtResource( 1 ) script = ExtResource( 1 )
[node name="TorsoMesh" type="MeshInstance" parent="."] [node name="TorsoMesh" type="MeshInstance" parent="."]
visible = false
mesh = SubResource( 1 ) mesh = SubResource( 1 )
material/0 = null material/0 = null
[node name="TorsoCollider" type="CollisionShape" parent="."] [node name="TorsoCollider" type="CollisionShape" parent="."]
transform = Transform( 0.8, 0, 0, 0, 0.8, 0, 0, 0, 0.8, 0, 0, 0 ) transform = Transform( 0.8, 0, 0, 0, 0.8, 0, 0, 0, 0.8, 0, 0, 0 )
shape = SubResource( 1 ) shape = SubResource( 2 )
[node name="FrontLeft" parent="." instance=ExtResource( 2 )] [node name="FrontLeft" parent="." instance=ExtResource( 2 )]
transform = Transform( 0.5, -1.62921e-07, -0.866025, -3.25841e-07, -1, 0, -0.866025, 2.82187e-07, -0.5, 0.6, 0, 1 ) transform = Transform( 0.5, -1.62921e-07, -0.866025, -3.25841e-07, -1, 0, -0.866025, 2.82187e-07, -0.5, 0.6, 0, 1 )
[node name="FrontRight" parent="." instance=ExtResource( 2 )] [node name="FrontRight" parent="." instance=ExtResource( 2 )]
transform = Transform( -0.5, 0, 0.866025, 0, 1, 0, -0.866025, 0, -0.5, -0.6, 0, 1 ) transform = Transform( 0.5, -7.54979e-08, 0.866025, -1.50996e-07, -1, 0, 0.866025, -1.30766e-07, -0.5, -0.6, 0, 1 )
[node name="Torso" parent="." instance=ExtResource( 3 )]
transform = Transform( 0.2, 0, 0, 0, -8.74228e-09, 0.2, 0, -0.2, -8.74228e-09, 0, 0, 0 )

16
Ingame/CameraFocus.gd Normal file
View File

@ -0,0 +1,16 @@
extends Spatial
onready var player1 = get_parent().get_node("Torso")
onready var player2 = get_parent().get_node("Torso2")
onready var camera = get_node("Camera")
func _process(delta: float) -> void:
var center = player2.transform.origin + (player1.transform.origin - player2.transform.origin) / 2.0
var distance = (player1.transform.origin - player2.transform.origin).length()
camera.fov = distance + 50.0
transform.origin = center

View File

@ -1,35 +1,43 @@
[gd_scene load_steps=6 format=2] [gd_scene load_steps=7 format=2]
[ext_resource path="res://BodyParts/Arm.tscn" type="PackedScene" id=1] [ext_resource path="res://BodyParts/Arm.tscn" type="PackedScene" id=1]
[ext_resource path="res://UI/UI.tscn" type="PackedScene" id=2] [ext_resource path="res://UI/UI.tscn" type="PackedScene" id=2]
[ext_resource path="res://BodyParts/BodyBase/BodyBase.tscn" type="PackedScene" id=3] [ext_resource path="res://BodyParts/BodyBase/BodyBase.tscn" type="PackedScene" id=3]
[ext_resource path="res://Ingame/Ingame.gd" type="Script" id=4] [ext_resource path="res://Ingame/Ingame.gd" type="Script" id=4]
[ext_resource path="res://Ingame/Arena.tscn" type="PackedScene" id=5] [ext_resource path="res://Ingame/Arena.tscn" type="PackedScene" id=5]
[ext_resource path="res://Ingame/CameraFocus.gd" type="Script" id=6]
[node name="InGame" type="Spatial"] [node name="InGame" type="Spatial"]
script = ExtResource( 4 ) script = ExtResource( 4 )
[node name="Camera" type="Camera" parent="."]
transform = Transform( -4.37114e-08, -0.5, 0.866025, 0, 0.866025, 0.5, -1, 2.18557e-08, -3.78552e-08, 17, 9, -2 )
[node name="UI" parent="." instance=ExtResource( 2 )] [node name="UI" parent="." instance=ExtResource( 2 )]
[node name="Arena" parent="." instance=ExtResource( 5 )] [node name="Arena" parent="." instance=ExtResource( 5 )]
[node name="Torso" parent="." instance=ExtResource( 3 )] [node name="Torso" parent="." instance=ExtResource( 3 )]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2, 0 )
[node name="Arm" parent="Torso/FrontLeft/Limb" index="0" instance=ExtResource( 1 )] [node name="Arm" parent="Torso/FrontLeft/Limb" index="0" instance=ExtResource( 1 )]
key = 65 key = 81
[node name="Arm" parent="Torso/FrontRight/Limb" index="0" instance=ExtResource( 1 )] [node name="Arm" parent="Torso/FrontRight/Limb" index="0" instance=ExtResource( 1 )]
key = 83 key = 87
[node name="Torso2" parent="." instance=ExtResource( 3 )] [node name="Torso2" parent="." instance=ExtResource( 3 )]
transform = Transform( -1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 0, 2, -10 )
[node name="Arm" parent="Torso2/FrontLeft/Limb" index="0" instance=ExtResource( 1 )] [node name="Arm" parent="Torso2/FrontLeft/Limb" index="0" instance=ExtResource( 1 )]
transform = Transform( 1, 2.84217e-14, 0, -2.84217e-14, 1, 0, 0, 0, 1, 0, 0, 0 ) transform = Transform( 1, 2.84217e-14, 0, -2.84217e-14, 1, 0, 0, 0, 1, 0, 0, 0 )
key = 79
[node name="Arm" parent="Torso2/FrontRight/Limb" index="0" instance=ExtResource( 1 )] [node name="Arm" parent="Torso2/FrontRight/Limb" index="0" instance=ExtResource( 1 )]
key = 80
[node name="CameraFocus" type="Spatial" parent="."]
script = ExtResource( 6 )
[node name="Camera" type="Camera" parent="CameraFocus"]
transform = Transform( -4.2222e-08, -0.707107, 0.707107, -1.13133e-08, 0.707107, 0.707107, -1, 2.18557e-08, -3.78552e-08, 19, 17, -2 )
[editable path="Torso"] [editable path="Torso"]