Characters now work fine

This commit is contained in:
Segey Lapin
2019-07-23 10:29:41 +03:00
parent 69cd38082e
commit 43c20e590b
11 changed files with 4202 additions and 33425 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -50,7 +50,6 @@ func _process(delta):
mon_labels[act_obj].text = act_obj.get_act()
add_child(mon_labels[act_obj])
mon_labels[act_obj].rect_position = camera.unproject_position(act_obj.global_transform.origin)
print("act3:", mon_labels[act_obj].text)
for k in monitored_objects:
var epos = k.global_transform.origin
var new_dist = opos.distance_squared_to(epos)
@@ -58,7 +57,6 @@ func _process(delta):
monitored_objects.erase(k)
mon_labels[k].queue_free()
mon_labels.erase(k)
print("removed label")
break
else:
mon_labels[k].rect_position = camera.unproject_position(k.global_transform.origin)

View File

@@ -2,6 +2,8 @@ extends KinematicBody
var orientation: Transform
var velocity: Vector3 = Vector3()
var skel: Skeleton
var anim_tree: AnimationTree
var aplay: AnimationPlayer
const GRAVITY = Vector3(0, -9.8, 0)
# Declare member variables here. Examples:
# var a = 2
@@ -10,7 +12,25 @@ const GRAVITY = Vector3(0, -9.8, 0)
# Called when the node enters the scene tree for the first time.
func _ready():
orientation = Transform()
skel = get_children()[0]
skel = get_children()[0].get_children()[0]
var queue = [self]
while queue.size() > 0:
var item = queue[0]
queue.pop_front()
if item is Skeleton:
skel = item
if item is AnimationTree:
anim_tree = item
if item is AnimationPlayer:
aplay = item
if skel != null && anim_tree != null && aplay != null:
break
for c in item.get_children():
queue.push_back(c)
for v in aplay.get_animation_list():
if v.ends_with("loop"):
var anim = aplay.get_animation(v)
anim.loop = true
add_to_group("characters")
add_to_group("activatable")
@@ -18,15 +38,15 @@ func get_act():
return "Talk"
func idle():
var sm: AnimationNodeStateMachinePlayback = $AnimationTree["parameters/base/playback"]
var sm: AnimationNodeStateMachinePlayback = anim_tree["parameters/base/playback"]
sm.travel("Idle")
func walk():
var sm: AnimationNodeStateMachinePlayback = $AnimationTree["parameters/base/playback"]
var sm: AnimationNodeStateMachinePlayback = anim_tree["parameters/base/playback"]
sm.travel("Walk")
func set_walk_speed(spd: float):
$AnimationTree["parameters/base/Walk/speed/scale"] = spd
anim_tree["parameters/base/Walk/speed/scale"] = spd
func get_walk_speed() -> float:
return $AnimationTree["parameters/base/Walk/speed/scale"]
return anim_tree["parameters/base/Walk/speed/scale"]
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
@@ -44,8 +64,8 @@ func walkto(target: Vector3, spd: float = 1.4):
func _process(delta):
orientation = global_transform
orientation.origin = Vector3()
var sm: AnimationNodeStateMachinePlayback = $AnimationTree["parameters/base/playback"]
var rm = $AnimationTree.get_root_motion_transform()
var sm: AnimationNodeStateMachinePlayback = anim_tree["parameters/base/playback"]
var rm = anim_tree.get_root_motion_transform()
orientation *= rm
var h_velocity = orientation.origin / delta
velocity.x = h_velocity.x

File diff suppressed because one or more lines are too long

View File

@@ -1,66 +1,96 @@
[gd_scene load_steps=14 format=2]
[gd_scene load_steps=19 format=2]
[ext_resource path="res://characters/female_2018.escn" type="PackedScene" id=1]
[ext_resource path="res://characters/character.gd" type="Script" id=1]
[ext_resource path="res://characters/female_2018.escn" type="PackedScene" id=2]
[sub_resource type="AnimationNodeAdd2" id=1]
[sub_resource type="AnimationNodeAnimation" id=2]
animation = "stand"
[sub_resource type="AnimationNodeAnimation" id=3]
animation = "additive-wiggling-loop"
[sub_resource type="AnimationNodeBlendTree" id=4]
nodes/Add2/node = SubResource( 1 )
nodes/Add2/position = Vector2( 580, 120 )
nodes/Animation/node = SubResource( 3 )
nodes/Animation/position = Vector2( 100, 260 )
"nodes/Animation 2/node" = SubResource( 2 )
"nodes/Animation 2/position" = Vector2( 120, 100 )
nodes/output/position = Vector2( 1020, 160 )
node_connections = [ "output", 0, "Add2", "Add2", 0, "Animation 2", "Add2", 1, "Animation" ]
[sub_resource type="AnimationNodeAnimation" id=3]
animation = "stand"
[sub_resource type="AnimationNodeAnimation" id=5]
[sub_resource type="AnimationNodeTimeScale" id=4]
[sub_resource type="AnimationNodeBlendTree" id=5]
nodes/Add2/node = SubResource( 1 )
nodes/Add2/position = Vector2( 500, 120 )
nodes/Animation/node = SubResource( 3 )
nodes/Animation/position = Vector2( 117, 81 )
"nodes/Animation 2/node" = SubResource( 2 )
"nodes/Animation 2/position" = Vector2( 151, 279 )
nodes/output/position = Vector2( 1040, 120 )
nodes/speed/node = SubResource( 4 )
nodes/speed/position = Vector2( 840, 120 )
node_connections = [ "speed", 0, "Add2", "output", 0, "speed", "Add2", 0, "Animation", "Add2", 1, "Animation 2" ]
[sub_resource type="AnimationNodeAdd2" id=6]
[sub_resource type="AnimationNodeAnimation" id=7]
animation = "additive-wiggling-loop"
[sub_resource type="AnimationNodeAnimation" id=8]
animation = "walk-loop"
[sub_resource type="AnimationNodeTimeScale" id=6]
[sub_resource type="AnimationNodeTimeScale" id=9]
[sub_resource type="AnimationNodeBlendTree" id=7]
nodes/Animation/node = SubResource( 5 )
nodes/Animation/position = Vector2( 80, 120 )
nodes/TimeScale/node = SubResource( 6 )
nodes/TimeScale/position = Vector2( 400, 120 )
nodes/output/position = Vector2( 820, 160 )
node_connections = [ "output", 0, "TimeScale", "TimeScale", 0, "Animation" ]
[sub_resource type="AnimationNodeBlendTree" id=10]
graph_offset = Vector2( 0, -89 )
nodes/Add2/node = SubResource( 6 )
nodes/Add2/position = Vector2( 600, 120 )
nodes/Animation/node = SubResource( 8 )
nodes/Animation/position = Vector2( 100, 60 )
"nodes/Animation 2/node" = SubResource( 7 )
"nodes/Animation 2/position" = Vector2( 100, 200 )
nodes/output/position = Vector2( 1120, 120 )
nodes/speed/node = SubResource( 9 )
nodes/speed/position = Vector2( 940, 120 )
node_connections = [ "speed", 0, "Add2", "output", 0, "speed", "Add2", 0, "Animation", "Add2", 1, "Animation 2" ]
[sub_resource type="AnimationNodeStateMachineTransition" id=8]
[sub_resource type="AnimationNodeStateMachineTransition" id=11]
[sub_resource type="AnimationNodeStateMachineTransition" id=9]
[sub_resource type="AnimationNodeStateMachineTransition" id=12]
[sub_resource type="AnimationNodeStateMachine" id=10]
states/Idle/node = SubResource( 4 )
states/Idle/position = Vector2( 194, 105 )
states/Walk/node = SubResource( 7 )
states/Walk/position = Vector2( 344, 217 )
transitions = [ "Idle", "Walk", SubResource( 8 ), "Walk", "Idle", SubResource( 9 ) ]
[sub_resource type="AnimationNodeStateMachine" id=13]
states/Idle/node = SubResource( 5 )
states/Idle/position = Vector2( 185, 43 )
states/Walk/node = SubResource( 10 )
states/Walk/position = Vector2( 328, 147 )
transitions = [ "Idle", "Walk", SubResource( 11 ), "Walk", "Idle", SubResource( 12 ) ]
start_node = "Idle"
[sub_resource type="AnimationNodeBlendTree" id=11]
graph_offset = Vector2( 0, -268.75 )
nodes/base/node = SubResource( 10 )
nodes/base/position = Vector2( 80, 140 )
nodes/output/position = Vector2( 420, 140 )
[sub_resource type="AnimationNodeBlendTree" id=14]
graph_offset = Vector2( 0, -54 )
nodes/base/node = SubResource( 13 )
nodes/base/position = Vector2( 220, 220 )
nodes/output/position = Vector2( 540, 220 )
node_connections = [ "output", 0, "base" ]
[sub_resource type="AnimationNodeStateMachinePlayback" id=12]
[sub_resource type="AnimationNodeStateMachinePlayback" id=15]
[node name="female_2018" index="0" instance=ExtResource( 1 )]
[sub_resource type="CapsuleShape" id=16]
radius = 0.2
height = 1.12362
[node name="AnimationTree" type="AnimationTree" parent="." index="1"]
tree_root = SubResource( 11 )
[node name="female_2018" type="KinematicBody"]
script = ExtResource( 1 )
[node name="female_2018" parent="." instance=ExtResource( 2 )]
[node name="AnimationTree" type="AnimationTree" parent="female_2018"]
tree_root = SubResource( 14 )
anim_player = NodePath("../female_2018/AnimationPlayer")
active = true
root_motion_track = NodePath(".:root")
parameters/base/playback = SubResource( 12 )
parameters/base/Idle/Add2/add_amount = 0.3
parameters/base/Walk/TimeScale/scale = 1.0
parameters/base/playback = SubResource( 15 )
parameters/base/Idle/Add2/add_amount = 0
parameters/base/Idle/speed/scale = 1.0
parameters/base/Walk/Add2/add_amount = 0
parameters/base/Walk/speed/scale = 1.0
[node name="CollisionShape" type="CollisionShape" parent="."]
transform = Transform( 1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0, 0.765693, 0 )
shape = SubResource( 16 )
[editable path="female_2018"]

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long