Prototype 2
This commit is contained in:
47
proto2/characters/character.gd
Normal file
47
proto2/characters/character.gd
Normal file
@@ -0,0 +1,47 @@
|
||||
extends KinematicBody
|
||||
var orientation: Transform
|
||||
var velocity: Vector3 = Vector3()
|
||||
var skel: Skeleton
|
||||
const GRAVITY = Vector3(0, -9.8, 0)
|
||||
# Declare member variables here. Examples:
|
||||
# var a = 2
|
||||
# var b = "text"
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
orientation = Transform()
|
||||
skel = get_children()[0]
|
||||
|
||||
func idle():
|
||||
var sm: AnimationNodeStateMachinePlayback = $AnimationTree["parameters/base/playback"]
|
||||
sm.travel("Idle")
|
||||
func walk():
|
||||
var sm: AnimationNodeStateMachinePlayback = $AnimationTree["parameters/base/playback"]
|
||||
sm.travel("Walk")
|
||||
func set_walk_speed(spd: float):
|
||||
$AnimationTree["parameters/base/Walk/speed/scale"] = spd
|
||||
func get_walk_speed() -> float:
|
||||
return $AnimationTree["parameters/base/Walk/speed/scale"]
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
#func _process(delta):
|
||||
# pass
|
||||
func _process(delta):
|
||||
orientation = global_transform
|
||||
orientation.origin = Vector3()
|
||||
var sm: AnimationNodeStateMachinePlayback = $AnimationTree["parameters/base/playback"]
|
||||
var rm = $AnimationTree.get_root_motion_transform()
|
||||
orientation *= rm
|
||||
var h_velocity = orientation.origin / delta
|
||||
velocity.x = h_velocity.x
|
||||
velocity.z = h_velocity.z
|
||||
if !is_on_floor():
|
||||
velocity += GRAVITY * delta
|
||||
velocity = move_and_slide(velocity, Vector3(0, 1, 0))
|
||||
if is_in_group("master"):
|
||||
orientation *= controls.frame_tf
|
||||
controls.frame_tf = Transform()
|
||||
orientation.origin = Vector3()
|
||||
orientation = orientation.orthonormalized()
|
||||
global_transform.basis = orientation.basis
|
||||
skel.rotation = Vector3()
|
||||
1062
proto2/characters/female_2018.escn.import
Normal file
1062
proto2/characters/female_2018.escn.import
Normal file
File diff suppressed because it is too large
Load Diff
66
proto2/characters/female_2018.tscn
Normal file
66
proto2/characters/female_2018.tscn
Normal file
@@ -0,0 +1,66 @@
|
||||
[gd_scene load_steps=14 format=2]
|
||||
|
||||
[ext_resource path="res://characters/female_2018.escn" type="PackedScene" id=1]
|
||||
|
||||
[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=5]
|
||||
animation = "walk-loop"
|
||||
|
||||
[sub_resource type="AnimationNodeTimeScale" id=6]
|
||||
|
||||
[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="AnimationNodeStateMachineTransition" id=8]
|
||||
|
||||
[sub_resource type="AnimationNodeStateMachineTransition" id=9]
|
||||
|
||||
[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 ) ]
|
||||
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 )
|
||||
node_connections = [ "output", 0, "base" ]
|
||||
|
||||
[sub_resource type="AnimationNodeStateMachinePlayback" id=12]
|
||||
|
||||
[node name="female_2018" index="0" instance=ExtResource( 1 )]
|
||||
|
||||
[node name="AnimationTree" type="AnimationTree" parent="." index="1"]
|
||||
tree_root = SubResource( 11 )
|
||||
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
|
||||
1062
proto2/characters/male_2018.escn.import
Normal file
1062
proto2/characters/male_2018.escn.import
Normal file
File diff suppressed because it is too large
Load Diff
29978
proto2/characters/male_2018.tscn
Normal file
29978
proto2/characters/male_2018.tscn
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user