Add frog legs

This commit is contained in:
karl 2020-02-02 12:14:27 +01:00
parent 416f492b30
commit 9cb581816f
7 changed files with 106 additions and 9 deletions

View File

@ -2,33 +2,35 @@
importer="texture" importer="texture"
type="StreamTexture" type="StreamTexture"
path="res://.import/froschtexture.png-4981f80e68642c0c23396f3b44826854.stex" path.s3tc="res://.import/froschtexture.png-4981f80e68642c0c23396f3b44826854.s3tc.stex"
path.etc2="res://.import/froschtexture.png-4981f80e68642c0c23396f3b44826854.etc2.stex"
metadata={ metadata={
"vram_texture": false "imported_formats": [ "s3tc", "etc2" ],
"vram_texture": true
} }
[deps] [deps]
source_file="res://3D Input/froschtexture.png" source_file="res://3D Input/froschtexture.png"
dest_files=[ "res://.import/froschtexture.png-4981f80e68642c0c23396f3b44826854.stex" ] dest_files=[ "res://.import/froschtexture.png-4981f80e68642c0c23396f3b44826854.s3tc.stex", "res://.import/froschtexture.png-4981f80e68642c0c23396f3b44826854.etc2.stex" ]
[params] [params]
compress/mode=0 compress/mode=2
compress/lossy_quality=0.7 compress/lossy_quality=0.7
compress/hdr_mode=0 compress/hdr_mode=0
compress/bptc_ldr=0 compress/bptc_ldr=0
compress/normal_map=0 compress/normal_map=0
flags/repeat=0 flags/repeat=true
flags/filter=true flags/filter=true
flags/mipmaps=false flags/mipmaps=true
flags/anisotropic=false flags/anisotropic=false
flags/srgb=2 flags/srgb=1
process/fix_alpha_border=true process/fix_alpha_border=true
process/premult_alpha=false process/premult_alpha=false
process/HDR_as_SRGB=false process/HDR_as_SRGB=false
process/invert_color=false process/invert_color=false
stream=false stream=false
size_limit=0 size_limit=0
detect_3d=true detect_3d=false
svg/scale=1.0 svg/scale=1.0

29
BodyParts/FrogLeg.gd Normal file
View File

@ -0,0 +1,29 @@
extends PushingBodyPart
onready var anim = get_node("Mesh/AnimationPlayer")
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
pass # Replace with function body.
func action():
anim.play("ArmatureAction")
func _is_animation_playing():
return anim.is_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 direction = (base.transform.basis.y - base.transform.basis.z).normalized() * 20.0
base.apply_impulse(offset, direction)
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta: float) -> void:
# pass

52
BodyParts/FrogLeg.tscn Normal file
View File

@ -0,0 +1,52 @@
[gd_scene load_steps=8 format=2]
[ext_resource path="res://BodyParts/PushingBodyPart.tscn" type="PackedScene" id=1]
[ext_resource path="res://BodyParts/FrogLeg.gd" type="Script" id=2]
[ext_resource path="res://3D Input/Fertige GLBs/Bein_Frosch.glb" type="PackedScene" id=3]
[ext_resource path="res://3D Input/froschtexture.png" type="Texture" id=4]
[sub_resource type="BoxShape" id=2]
extents = Vector3( 0.649825, 2.07811, 1.64282 )
[sub_resource type="SphereShape" id=3]
radius = 0.115004
[sub_resource type="SpatialMaterial" id=1]
albedo_texture = ExtResource( 4 )
roughness = 0.3
[node name="FrogLeg" instance=ExtResource( 1 )]
transform = Transform( -1, 8.74228e-08, 0, -8.74228e-08, -1, 0, 0, 0, 1, 0, 0, 0 )
script = ExtResource( 2 )
[node name="PartCollider" parent="." index="0"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0.21377, -0.911304, -3.94992 )
shape = SubResource( 2 )
[node name="TouchArea" parent="." index="1"]
transform = Transform( 2.2019, -0.624093, -2.57245, 1.35866, 3.13817, 0.40161, 2.27179, -1.27191, 2.25313, 0.307055, -2.49965, -4.98782 )
[node name="CollisionShape" type="CollisionShape" parent="TouchArea" index="0"]
shape = SubResource( 3 )
[node name="Mesh" parent="." index="2" instance=ExtResource( 3 )]
transform = Transform( -1.13133e-08, 4.2222e-08, 1, 0.965926, 0.258819, 0, -0.258819, 0.965926, -4.37114e-08, 0.734499, -2.94707, -2.68774 )
[node name="Skeleton" parent="Mesh/Armature" index="0"]
bones/3/bound_children = [ NodePath("BoneAttachment") ]
[node name="froschbein" parent="Mesh/Armature/Skeleton" index="0"]
transform = Transform( 1, -1.49012e-08, 0, 0, 1, -5.96046e-08, 0, 2.98023e-08, 1, 0, 0, 0 )
material/0 = SubResource( 1 )
[node name="BoneAttachment" type="BoneAttachment" parent="Mesh/Armature/Skeleton" index="1"]
transform = Transform( -0.207654, -0.97489, 0.0804374, -0.106263, -0.059262, -0.99257, 0.972414, -0.214658, -0.091288, 0.208948, 1.33566, -0.895561 )
bone_name = "bone_3"
[node name="RemoteTransform" type="RemoteTransform" parent="Mesh/Armature/Skeleton/BoneAttachment" index="0"]
remote_path = NodePath("../../../../../TouchArea")
[node name="AnimationPlayer" parent="Mesh" index="2"]
playback_speed = 2.0
[editable path="Mesh"]

View File

@ -4,6 +4,10 @@ extends PushingBodyPart
onready var anim = get_node("Mesh/AnimationPlayer") onready var anim = get_node("Mesh/AnimationPlayer")
func _is_animation_playing():
return anim.is_playing()
func action(): func action():
anim.play("ArmatureAction") anim.play("ArmatureAction")

View File

@ -9,6 +9,10 @@ func _ready() -> void:
pass # Replace with function body. pass # Replace with function body.
func _is_animation_playing():
return anim.is_playing()
func action(): func action():
anim.play("ArmatureAction") anim.play("ArmatureAction")

View File

@ -11,8 +11,13 @@ func _ready() -> void:
touch_area.connect("body_entered", self, "_on_touch_area_entered") touch_area.connect("body_entered", self, "_on_touch_area_entered")
# Override in derived classes!
func _is_animation_playing():
return true
func _on_touch_area_entered(body): func _on_touch_area_entered(body):
if body.name != base.name: if body.name != base.name and _is_animation_playing():
if body.is_in_group("Terrain"): if body.is_in_group("Terrain"):
push(body) push(body)
elif body.is_in_group("Player"): elif body.is_in_group("Player"):

View File

@ -6,3 +6,4 @@ var bodyparts : Dictionary
func _ready(): func _ready():
bodyparts["Human Arm"] = load("res://BodyParts/HumanArm.tscn") bodyparts["Human Arm"] = load("res://BodyParts/HumanArm.tscn")
bodyparts["Human Leg"] = load("res://BodyParts/HumanLeg.tscn") bodyparts["Human Leg"] = load("res://BodyParts/HumanLeg.tscn")
bodyparts["Frog Leg"] = load("res://BodyParts/FrogLeg.tscn")