This commit is contained in:
mathias 2020-02-02 16:14:23 +01:00
commit 22b953d1f4
11 changed files with 71 additions and 24 deletions

Binary file not shown.

View File

@ -20,16 +20,17 @@ func _physics_process(delta):
var rot_vector = (-transform.basis.z).cross(ground.transform.basis.y)
var _should_fix_torque = false
for body in get_colliding_bodies():
if body.name == "StaticBody":
if current_angle > 0.3:
apply_torque_impulse(rot_vector * current_angle * 7)
apply_impulse(transform.basis.xform(Vector3.ZERO), -(transform.basis.y) * 0.05)
elif current_angle > 0.05:
apply_torque_impulse(-(rot_vector * current_angle * 5))
else:
angular_velocity = Vector3.ZERO
_should_fix_torque = true
if _should_fix_torque:
if current_angle > 0.3:
apply_torque_impulse(rot_vector * current_angle * 7)
apply_impulse(transform.basis.xform(Vector3.ZERO), -(transform.basis.y) * 0.05)
# if current_angle < 0.1:
# angular_velocity.x = 0
for axis in angular_velocity:
if axis > 10:
axis -= axis * 0.75

View File

@ -16,6 +16,7 @@ mass = 1.73469
gravity_scale = 1.5
contacts_reported = 5
contact_monitor = true
angular_damp = 0.5
script = ExtResource( 1 )
[node name="TorsoCollider" type="CollisionShape" parent="."]

View File

@ -14,6 +14,8 @@ albedo_texture = ExtResource( 4 )
[node name="Bullhead" instance=ExtResource( 1 )]
transform = Transform( -1, 3.25841e-07, 0, 5.30863e-14, 1.62921e-07, -1, -3.25841e-07, -1, -1.62921e-07, 0, -3.28412, 0.289329 )
script = ExtResource( 2 )
cost = 35.0
damage = 30.0
[node name="TouchArea" parent="." index="1"]
transform = Transform( -1.71568, 8.52651e-14, 1.49989e-07, 1.27871e-07, -0.89673, 1.46268, 7.83945e-08, 1.46267, 0.89673, -0.002635, -0.0220304, -0.00495291 )

View File

@ -19,7 +19,7 @@ func _is_animation_playing():
func push(body):
# We multiply by 0.1 because we only want it to spin slightly, it should mostly go up
var offset = transform.basis.xform(Vector3.ZERO) #transform.basis.xform(touch_area.global_transform.origin - base.global_transform.origin) * 0.5
var offset = transform.basis.xform(-touch_area.global_transform.origin + base.global_transform.origin) * 0.1
var direction = (base.transform.basis.y - base.transform.basis.z).normalized() * 20.0
base.apply_impulse(offset, direction)

View File

@ -12,7 +12,7 @@ extents = Vector3( 0.533899, 0.405119, 2.17243 )
radius = 0.101154
[node name="HumanArm" instance=ExtResource( 1 )]
transform = Transform( -4.37114e-08, 1, 4.37114e-08, 0, -4.37114e-08, 1, 1, 4.37114e-08, 1.91069e-15, 0, 0, 0 )
transform = Transform( -9.33901e-08, 1, 6.32685e-08, 0.419008, -1.83154e-08, 0.907982, 0.907982, 1.11307e-07, -0.419008, 0, 0, 0 )
script = ExtResource( 2 )
cost = 10.0
damage = 5.0
@ -22,7 +22,7 @@ transform = Transform( 0.796097, 0.0325159, -0.604295, 0, 0.998555, 0.0537302, 0
shape = SubResource( 1 )
[node name="TouchArea" parent="." index="1"]
transform = Transform( -0.118289, 2.18551, 2.52493, -3.31556, -0.378316, 0.172131, 0.398447, -2.49922, 2.18193, -0.0255739, -0.127111, -3.79535 )
transform = Transform( -0.118288, 2.18551, 2.52493, -3.31556, -0.378316, 0.172131, 0.398447, -2.49922, 2.18193, -0.025574, -0.127111, -3.79535 )
[node name="CollisionShape" type="CollisionShape" parent="TouchArea" index="0"]
shape = SubResource( 2 )
@ -40,9 +40,6 @@ remote_path = NodePath("../../../../../TouchArea")
[node name="AnimationPlayer" parent="Mesh" index="2"]
playback_speed = 3.0
[node name="ActionSound" parent="." index="3"]
unit_db = 0.0
[node name="PushSound" parent="." index="4"]
stream = ExtResource( 3 )

View File

@ -16,20 +16,16 @@ func _is_animation_playing():
func action():
anim.play("ArmatureAction")
# Apply a slight counter force
var offset = transform.basis.xform(Vector3.ZERO) #transform.basis.xform(touch_area.global_transform.origin - base.global_transform.origin) * 0.5
var direction = -(base.transform.basis.y - base.transform.basis.z).normalized() * 0.5
base.apply_impulse(offset, direction)
func push(body):
# We multiply by 0.1 because we only want it to spin slightly, it should mostly go up
var offset = transform.basis.xform(Vector3.ZERO) #transform.basis.xform(touch_area.global_transform.origin - base.global_transform.origin) * 0.5
var offset = transform.basis.xform(touch_area.global_transform.origin - base.global_transform.origin) * 0.3
var direction = (base.transform.basis.y - base.transform.basis.z).normalized() * 10.0
base.apply_impulse(offset, direction)
#base.apply_torque_impulse(base.transform.basis.y * 20.0)
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta: float) -> void:
# pass

22
BodyParts/Wings.gd Normal file
View File

@ -0,0 +1,22 @@
extends BodyPart
onready var anim = get_node("Mesh/AnimationPlayer")
onready var timer = get_node("Timer")
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
pass # Replace with function body.
func action():
if timer.time_left == 0:
anim.play("ArmatureAction")
var offset = transform.basis.xform(Vector3.ZERO)
var direction = (-base.transform.basis.z).normalized() * 30.0
base.apply_impulse(offset, direction)
timer.start()

26
BodyParts/Wings.tscn Normal file
View File

@ -0,0 +1,26 @@
[gd_scene load_steps=5 format=2]
[ext_resource path="res://3D Input/Fertige GLBs/vogel_flügel.glb" type="PackedScene" id=1]
[ext_resource path="res://BodyParts/BodyPart.tscn" type="PackedScene" id=2]
[ext_resource path="res://BodyParts/Wings.gd" type="Script" id=3]
[sub_resource type="BoxShape" id=1]
extents = Vector3( 2.75562, 0.605394, 2.0419 )
[node name="Wings" instance=ExtResource( 2 )]
transform = Transform( 0.440754, -0.897628, 0, 0.897628, 0.440754, 0, 0, 0, 1, 0, 0, 0 )
script = ExtResource( 3 )
cost = 30.0
[node name="PartCollider" parent="." index="0"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -2.80638 )
shape = SubResource( 1 )
[node name="Mesh" parent="." index="2" instance=ExtResource( 1 )]
transform = Transform( -0.517952, -0.85541, 1.14363e-07, 4.41231e-09, 1.31023e-07, 1, -0.85541, 0.517952, -6.40892e-08, 1.08802, 0.236862, -3.57712 )
[node name="Timer" type="Timer" parent="." index="3"]
wait_time = 1.5
one_shot = true
[editable path="Mesh"]

View File

@ -10,4 +10,5 @@ func _ready():
bodyparts["Gorilla Arm"] = load("res://BodyParts/GorillaArm.tscn")
bodyparts["Horse Leg"] = load("res://BodyParts/HorseLeg.tscn")
bodyparts["Chicken Head"] = load("res://BodyParts/ChickenHead.tscn")
bodyparts["Wings"] = load("res://BodyParts/Wings.tscn")
bodyparts["Bull Head"] = load("res://BodyParts/BullHead.tscn")

View File

@ -92,6 +92,7 @@ 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 )
far = 500.0
[connection signal="pressed" from="UI/ESC Menu" to="." method="_on_ESC_Menu_pressed"]
[editable path="Arena"]