Fix a thing with impulse offset + new camera

This commit is contained in:
karl 2020-02-01 16:06:53 +01:00
parent f984745822
commit 3ec9bac0da
5 changed files with 31 additions and 11 deletions

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(global_transform.origin - touch_area.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

@ -13,8 +13,6 @@ radius = 0.591769
[node name="Arm" instance=ExtResource( 1 )] [node name="Arm" instance=ExtResource( 1 )]
script = ExtResource( 3 ) script = ExtResource( 3 )
key = 0
damage = 10.0
[node name="PartCollider" parent="." index="0"] [node name="PartCollider" parent="." index="0"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -2.83 ) transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -2.83 )
@ -29,14 +27,14 @@ visible = false
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 ) transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )
[node name="BoneAttachment" type="BoneAttachment" parent="Mesh/Armature/Skeleton" index="1"] [node name="BoneAttachment" type="BoneAttachment" parent="Mesh/Armature/Skeleton" index="1"]
transform = Transform( 1, -1.98292e-23, -3.18966e-24, 6.71348e-24, -9.49949e-08, 1, -2.07636e-23, -1, -9.49949e-08, -2.23781e-16, -0.0078205, -5.05441 ) transform = Transform( 1, -1.98247e-23, -2.98292e-24, 6.50669e-24, -9.49949e-08, 1, -2.07684e-23, -1, -9.49949e-08, -2.23781e-16, -0.0078205, -5.05441 )
bone_name = "bone_2" bone_name = "bone_2"
[node name="RemoteTransform" type="RemoteTransform" parent="Mesh/Armature/Skeleton/BoneAttachment" index="0"] [node name="RemoteTransform" type="RemoteTransform" parent="Mesh/Armature/Skeleton/BoneAttachment" index="0"]
remote_path = NodePath("../../../../../TouchArea") remote_path = NodePath("../../../../../TouchArea")
[node name="TouchArea" parent="." index="2"] [node name="TouchArea" parent="." index="2"]
transform = Transform( 1, -1.98292e-23, -3.18966e-24, 6.71348e-24, -9.49949e-08, 1, -2.07636e-23, -1, -9.49949e-08, -2.23781e-16, -0.0078205, -5.05441 ) transform = Transform( 1, -1.98247e-23, -2.98292e-24, 6.50669e-24, -9.49949e-08, 1, -2.07684e-23, -1, -9.49949e-08, -2.23781e-16, -0.0078205, -5.05441 )
[node name="CollisionShape" type="CollisionShape" parent="TouchArea" index="0"] [node name="CollisionShape" type="CollisionShape" parent="TouchArea" index="0"]
transform = Transform( 1, 2.98291e-24, -1.98247e-23, -2.07684e-23, -9.49949e-08, -1, -6.50669e-24, 1, -9.49949e-08, 0, 0, 0 ) transform = Transform( 1, 2.98291e-24, -1.98247e-23, -2.07684e-23, -9.49949e-08, -1, -6.50669e-24, 1, -9.49949e-08, 0, 0, 0 )

View File

@ -17,7 +17,7 @@ shape = SubResource( 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="Mesh" parent="." instance=ExtResource( 3 )] [node name="Mesh" 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 ) 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,24 +1,24 @@
[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="Torso" parent="." instance=ExtResource( 3 )] [node name="Torso" parent="." instance=ExtResource( 3 )]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 3.02111, 0 ) transform = Transform( -1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 0, 3.02111, 28.4014 )
[node name="Arm" parent="Torso/FrontLeft" index="1" instance=ExtResource( 1 )] [node name="Arm" parent="Torso/FrontLeft" index="1" instance=ExtResource( 1 )]
transform = Transform( 1, 2.84217e-14, 0, -2.84217e-14, 1, 0, 0, 0, 1, 0, 0, 0 )
key = 83 key = 83
[node name="Arm" parent="Torso/FrontRight" index="1" instance=ExtResource( 1 )] [node name="Arm" parent="Torso/FrontRight" index="1" instance=ExtResource( 1 )]
transform = Transform( 1, 7.10543e-15, 0, -2.13163e-14, 1, 0, 0, 7.10543e-15, 1, 0, 0, 0 )
key = 65 key = 65
[node name="Torso2" parent="." instance=ExtResource( 3 )] [node name="Torso2" parent="." instance=ExtResource( 3 )]
@ -35,6 +35,12 @@ key = 87
[node name="Arena" parent="." instance=ExtResource( 5 )] [node name="Arena" parent="." instance=ExtResource( 5 )]
[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, 14, 13, 0 )
[editable path="Torso"] [editable path="Torso"]
[editable path="Torso2"] [editable path="Torso2"]