adding animation
This commit is contained in:
parent
6a7810445b
commit
2e0070e868
3 changed files with 147 additions and 63 deletions
|
@ -5,66 +5,84 @@
|
|||
[node name="character" instance=ExtResource( "1_2jxjm" )]
|
||||
|
||||
[node name="Skeleton3D" parent="char_grp/rig" index="0"]
|
||||
bones/2/rotation = Quaternion(-0.271757, 0.626496, -0.507842, 0.525117)
|
||||
bones/5/rotation = Quaternion(-0.445372, 0.390831, -0.410612, 0.693032)
|
||||
bones/6/rotation = Quaternion(-0.0372555, -0.0374979, 0.122351, 0.991078)
|
||||
bones/9/rotation = Quaternion(-0.55327, -0.021387, -0.0662289, 0.830089)
|
||||
bones/12/rotation = Quaternion(-0.69924, -0.00070756, -0.0840618, 0.709928)
|
||||
bones/14/rotation = Quaternion(-0.281124, -0.000329497, -0.0339629, 0.95907)
|
||||
bones/17/rotation = Quaternion(-0.541706, 0.00703882, -0.0505262, 0.839019)
|
||||
bones/20/rotation = Quaternion(-0.727666, -0.00506352, -0.0876433, 0.680291)
|
||||
bones/22/rotation = Quaternion(-0.340549, -0.00194646, -0.041411, 0.939312)
|
||||
bones/25/rotation = Quaternion(-0.55521, 0.0120764, -0.0438172, 0.830467)
|
||||
bones/28/rotation = Quaternion(-0.864959, 0.00479228, -0.103815, 0.490964)
|
||||
bones/30/rotation = Quaternion(-0.171698, -0.00446994, -0.0205173, 0.984926)
|
||||
bones/38/rotation = Quaternion(-0.38892, -0.00569116, -0.0466897, 0.92007)
|
||||
bones/41/rotation = Quaternion(0.0189979, 0.0622678, -0.039629, 0.997091)
|
||||
bones/44/rotation = Quaternion(-0.352984, -0.0533485, -0.00972458, 0.934057)
|
||||
bones/47/rotation = Quaternion(-0.491492, -0.286184, 0.496952, 0.655418)
|
||||
bones/50/rotation = Quaternion(-0.440024, -0.360322, 0.385434, 0.726628)
|
||||
bones/53/rotation = Quaternion(1.24162e-07, -0.0289177, 2.77174e-07, 0.999582)
|
||||
bones/55/rotation = Quaternion(-0.445372, 0.390831, -0.410612, 0.693032)
|
||||
bones/56/rotation = Quaternion(-2.72248e-07, -0.040541, -1.08628e-07, 0.999178)
|
||||
bones/60/rotation = Quaternion(-0.502103, 0.436597, -0.652123, 0.363333)
|
||||
bones/65/rotation = Quaternion(-0.519517, -0.442971, 0.636258, 0.359241)
|
||||
bones/66/rotation = Quaternion(9.07769e-10, 0.0551515, 3.5838e-08, 0.998478)
|
||||
bones/70/rotation = Quaternion(-0.440024, -0.360322, 0.385434, 0.726628)
|
||||
bones/71/rotation = Quaternion(-0.067789, -0.0294414, -0.0321137, 0.996748)
|
||||
bones/74/rotation = Quaternion(-0.529658, 0.0176954, 0.0583603, 0.846016)
|
||||
bones/77/rotation = Quaternion(-0.686348, 0.000695412, 0.0817067, 0.722669)
|
||||
bones/79/rotation = Quaternion(-0.325638, 0.000781165, 0.0388156, 0.944697)
|
||||
bones/82/rotation = Quaternion(-0.508272, -0.0129833, 0.0348485, 0.860393)
|
||||
bones/85/rotation = Quaternion(-0.788088, 0.00548676, 0.0939959, 0.608319)
|
||||
bones/90/rotation = Quaternion(0.0583021, -0.0664381, 0.18425, 0.978897)
|
||||
bones/93/rotation = Quaternion(-0.325608, 0.00672599, -0.0201309, 0.945267)
|
||||
bones/95/rotation = Quaternion(-0.476819, 0.0786276, -0.0477728, 0.874173)
|
||||
bones/98/rotation = Quaternion(-0.474577, -0.0113585, 0.0306311, 0.879608)
|
||||
bones/101/rotation = Quaternion(-0.781749, -0.0043309, 0.0929099, 0.616618)
|
||||
bones/103/rotation = Quaternion(-0.357714, 0.00928428, 0.0423253, 0.932826)
|
||||
bones/106/rotation = Quaternion(-0.574211, 0.0203224, 0.0987876, 0.812471)
|
||||
bones/109/rotation = Quaternion(-0.663777, 0.0235976, 0.0521688, 0.745736)
|
||||
bones/111/rotation = Quaternion(-0.361751, 0.00527712, 0.0430036, 0.931268)
|
||||
bones/112/rotation = Quaternion(0.0097308, -0.701742, -0.712346, 0.00508848)
|
||||
bones/113/rotation = Quaternion(-0.0911941, -0.00258285, 0.000984978, 0.995829)
|
||||
bones/116/rotation = Quaternion(0.080616, 0.00590208, 0.00270844, 0.996724)
|
||||
bones/120/rotation = Quaternion(0.105174, 0.00605958, 0.0129845, 0.994351)
|
||||
bones/123/rotation = Quaternion(-0.562449, 0.324106, 0.455498, 0.609203)
|
||||
bones/125/rotation = Quaternion(-0.539888, -0.0493987, 0.199217, 0.816329)
|
||||
bones/129/rotation = Quaternion(-0.558722, -0.301251, -0.453266, 0.625802)
|
||||
bones/131/rotation = Quaternion(-0.508332, 0.0333607, -0.240729, 0.826157)
|
||||
bones/139/rotation = Quaternion(0.0980113, -0.0899481, -0.0867249, 0.98731)
|
||||
bones/140/rotation = Quaternion(-0.0310007, 0.0719017, 0.355743, 0.931298)
|
||||
bones/142/rotation = Quaternion(0.470828, 0.517658, -0.563252, 0.439429)
|
||||
bones/143/rotation = Quaternion(0.00477369, 0.990276, 0.139034, 0.000545654)
|
||||
bones/144/rotation = Quaternion(0.105475, -3.99246e-08, -0.0774747, 0.991399)
|
||||
bones/148/rotation = Quaternion(0.0834681, -3.02306e-08, 0.0769496, 0.993535)
|
||||
bones/151/rotation = Quaternion(0.0726204, 0.130697, 0.0872612, 0.984901)
|
||||
bones/152/rotation = Quaternion(0.0219061, -0.0761316, -0.353842, 0.931944)
|
||||
bones/154/rotation = Quaternion(0.474683, -0.474536, 0.557822, 0.488187)
|
||||
bones/155/rotation = Quaternion(0.0047883, -0.989589, -0.143844, 0.0006509)
|
||||
bones/156/rotation = Quaternion(-0.492611, 0.329333, -0.498554, 0.632707)
|
||||
bones/162/rotation = Quaternion(0.000208666, -0.699219, -0.714693, 0.0175177)
|
||||
bones/163/rotation = Quaternion(-0.0303771, 0.00768932, 0.00157884, 0.999508)
|
||||
bones/2/position = Vector3(0.0784359, 0.0517285, 0.678281)
|
||||
bones/2/rotation = Quaternion(-0.307525, 0.607371, -0.550181, 0.48356)
|
||||
bones/5/position = Vector3(0.195291, -0.0485863, 1.06218)
|
||||
bones/5/rotation = Quaternion(-0.412464, 0.410276, -0.4694, 0.664237)
|
||||
bones/6/rotation = Quaternion(-0.0582304, -0.001603, 0.13642, 0.988937)
|
||||
bones/9/rotation = Quaternion(-0.561453, -0.0231588, -0.0693159, 0.824275)
|
||||
bones/12/rotation = Quaternion(-0.728827, -0.000737273, -0.0876188, 0.679069)
|
||||
bones/14/rotation = Quaternion(-0.255634, -0.000952704, -0.0306647, 0.966287)
|
||||
bones/17/rotation = Quaternion(-0.538324, 0.00476671, -0.0535266, 0.841022)
|
||||
bones/20/rotation = Quaternion(-0.749389, -0.00521458, -0.0902596, 0.655929)
|
||||
bones/22/rotation = Quaternion(-0.356563, -0.00269137, -0.0429802, 0.933278)
|
||||
bones/25/rotation = Quaternion(-0.571621, 0.0065649, -0.0542876, 0.818694)
|
||||
bones/28/rotation = Quaternion(-0.881185, 0.00488197, -0.105762, 0.460765)
|
||||
bones/30/rotation = Quaternion(-0.0330361, -0.00086033, -0.00394803, 0.999446)
|
||||
bones/33/rotation = Quaternion(-0.576826, -0.000943438, -0.0732803, 0.813573)
|
||||
bones/36/rotation = Quaternion(-0.736402, 0.000100009, -0.0884911, 0.670732)
|
||||
bones/38/rotation = Quaternion(-0.405865, -0.00593874, -0.0487245, 0.912614)
|
||||
bones/41/rotation = Quaternion(-0.0302296, 0.0724104, 0.0330607, 0.996368)
|
||||
bones/44/rotation = Quaternion(-0.349376, -0.0527748, -0.00937361, 0.935448)
|
||||
bones/46/rotation = Quaternion(-0.32151, -0.0498396, -0.0243373, 0.94528)
|
||||
bones/47/position = Vector3(-0.168592, -0.0251667, 1.17796)
|
||||
bones/47/rotation = Quaternion(-0.487883, -0.308038, 0.533589, 0.618357)
|
||||
bones/50/position = Vector3(-0.212763, -0.0307593, 1.06338)
|
||||
bones/50/rotation = Quaternion(-0.44292, -0.369823, 0.446111, 0.684133)
|
||||
bones/53/rotation = Quaternion(1.75916e-08, -0.0408464, 2.62749e-07, 0.999165)
|
||||
bones/55/position = Vector3(0.195291, -0.0485863, 1.06218)
|
||||
bones/55/rotation = Quaternion(-0.412464, 0.410276, -0.4694, 0.664237)
|
||||
bones/56/rotation = Quaternion(-2.78673e-07, -0.00463593, -6.10614e-08, 0.999989)
|
||||
bones/60/position = Vector3(0.112976, 0.0964934, 0.467957)
|
||||
bones/60/rotation = Quaternion(-0.462333, 0.468867, -0.631178, 0.409908)
|
||||
bones/61/rotation = Quaternion(-3.21937e-08, -2.43326e-05, 1.38859e-07, 1)
|
||||
bones/65/position = Vector3(-0.120237, 0.0984, 0.466783)
|
||||
bones/65/rotation = Quaternion(-0.514008, -0.439281, 0.597306, 0.43134)
|
||||
bones/66/rotation = Quaternion(3.32551e-09, 0.000635834, -3.92964e-08, 1)
|
||||
bones/70/position = Vector3(-0.212763, -0.0307593, 1.06338)
|
||||
bones/70/rotation = Quaternion(-0.44292, -0.369823, 0.446111, 0.684133)
|
||||
bones/71/rotation = Quaternion(-0.0888094, -0.0427847, -0.040495, 0.994305)
|
||||
bones/74/rotation = Quaternion(-0.549527, 0.0206711, 0.0642086, 0.832749)
|
||||
bones/77/rotation = Quaternion(-0.712915, 0.000721268, 0.0848697, 0.696096)
|
||||
bones/79/rotation = Quaternion(-0.337481, 0.000809509, 0.040228, 0.940472)
|
||||
bones/82/rotation = Quaternion(-0.536816, -0.0134173, 0.0392708, 0.842678)
|
||||
bones/85/rotation = Quaternion(-0.810184, 0.00563999, 0.0966318, 0.578128)
|
||||
bones/87/rotation = Quaternion(-0.421931, 0.00252161, 0.0506926, 0.905206)
|
||||
bones/90/rotation = Quaternion(0.0643552, -0.081459, 0.16902, 0.98013)
|
||||
bones/93/rotation = Quaternion(-0.299015, 0.00640381, -0.0178892, 0.954059)
|
||||
bones/95/rotation = Quaternion(-0.541157, 0.100274, -0.0506472, 0.833385)
|
||||
bones/98/rotation = Quaternion(-0.510709, -0.0128139, 0.0344355, 0.858968)
|
||||
bones/101/rotation = Quaternion(-0.807481, -0.00447452, 0.0959691, 0.582017)
|
||||
bones/103/rotation = Quaternion(-0.344878, 0.00895126, 0.0408073, 0.937717)
|
||||
bones/106/rotation = Quaternion(-0.5979, 0.0224629, 0.102745, 0.794641)
|
||||
bones/109/rotation = Quaternion(-0.696134, 0.0247606, 0.0571147, 0.715208)
|
||||
bones/111/rotation = Quaternion(-0.382943, 0.00558611, 0.0455238, 0.922632)
|
||||
bones/112/position = Vector3(-0.00500953, 0.0246192, 0.912242)
|
||||
bones/112/rotation = Quaternion(0.00343598, 0.721315, 0.692544, 0.00867646)
|
||||
bones/113/rotation = Quaternion(-0.0969781, -0.00354056, 0.00115181, 0.995279)
|
||||
bones/116/rotation = Quaternion(0.0514513, 0.000389628, 0.00320071, 0.99867)
|
||||
bones/120/rotation = Quaternion(0.0991512, 0.00790459, 0.0157262, 0.994917)
|
||||
bones/123/rotation = Quaternion(-0.569571, 0.338408, 0.428413, 0.614434)
|
||||
bones/125/rotation = Quaternion(-0.536876, -0.0710889, 0.127554, 0.830927)
|
||||
bones/129/rotation = Quaternion(-0.567206, -0.317191, -0.428263, 0.6279)
|
||||
bones/131/rotation = Quaternion(-0.531383, 0.0564132, -0.1734, 0.827274)
|
||||
bones/139/rotation = Quaternion(0.068824, -0.0593719, -0.0395242, 0.995076)
|
||||
bones/140/rotation = Quaternion(-0.0110398, 0.0651224, 0.228032, 0.971411)
|
||||
bones/142/rotation = Quaternion(0.455328, 0.508674, -0.524066, 0.509197)
|
||||
bones/143/rotation = Quaternion(0.00477451, 0.990241, 0.139282, 0.000551155)
|
||||
bones/144/rotation = Quaternion(0.071107, -3.28281e-08, -0.035449, 0.996839)
|
||||
bones/148/rotation = Quaternion(0.0631727, -2.59838e-08, 0.0370233, 0.997316)
|
||||
bones/151/rotation = Quaternion(0.0578145, 0.129246, 0.0449697, 0.988904)
|
||||
bones/152/rotation = Quaternion(0.0279504, -0.0821424, -0.216058, 0.972518)
|
||||
bones/154/rotation = Quaternion(0.432166, -0.505584, 0.527497, 0.528549)
|
||||
bones/155/rotation = Quaternion(0.00478173, -0.989898, -0.141701, 0.000603255)
|
||||
bones/156/position = Vector3(0.153223, -0.0353354, 1.17692)
|
||||
bones/156/rotation = Quaternion(-0.474798, 0.336839, -0.57185, 0.578009)
|
||||
bones/159/position = Vector3(-0.0871826, 0.053523, 0.677313)
|
||||
bones/159/rotation = Quaternion(-0.355482, -0.565428, 0.520193, 0.532281)
|
||||
bones/162/position = Vector3(-0.00474008, 0.00373837, 1.40049)
|
||||
bones/162/rotation = Quaternion(-0.019387, -0.688605, -0.724871, 0.00300917)
|
||||
bones/163/rotation = Quaternion(-0.0188115, 0.0195966, 0.00214514, 0.999629)
|
||||
|
||||
[node name="AnimationPlayer" parent="." index="1"]
|
||||
autoplay = "CHAR_idle_bored"
|
||||
|
|
|
@ -17,7 +17,7 @@ const ZOOM_Y = 0.05
|
|||
const ZOOM_Z = 0.1
|
||||
const ZOOM_STEP = 0.1
|
||||
const ZOOM_MIN = 0.2
|
||||
const ZOOM_MAX = 2.0
|
||||
const ZOOM_MAX = 3.0
|
||||
|
||||
const SPEED_ROTATE = PI
|
||||
const PI_2 = PI / 2.0
|
||||
|
@ -38,6 +38,47 @@ var reconciliate_rotate_camera_player:bool = true
|
|||
var is_run:bool = false
|
||||
var zoom:float = 1.0
|
||||
var tps:bool = true
|
||||
var animation_object:AnimationPlayer = null
|
||||
var anim_idle:String = "CHAR_idle_bored"
|
||||
var anim_run:String = "CHAR_run"
|
||||
var anim_run_backward:String = "CHAR_run backward"
|
||||
var anim_sitting_ground_idle:String = "CHAR_sitting_ground_idle"
|
||||
var anim_strafe_left_walk:String = "CHAR_strafe_left_walk"
|
||||
var anim_strafe_right_walk:String = "CHAR_strafe_right_walk"
|
||||
var anim_walk:String = "CHAR_walk"
|
||||
var anim_walk_backward:String = "CHAR_walk_backward"
|
||||
var current_anim:String = anim_idle
|
||||
|
||||
|
||||
func search_animation( obj:Node , root:String = "/") -> bool:
|
||||
var ret:bool = false
|
||||
for i in obj.get_children():
|
||||
print("DEBUG - search_animation: " + root + String(i.get_name()))
|
||||
if i.get_name() == "AnimationPlayer" or i.get_name() == "animation_player":
|
||||
animation_object = i
|
||||
return true
|
||||
else:
|
||||
ret = search_animation(i, root + String(i.get_name()) + "/" )
|
||||
if ret == true:
|
||||
return ret
|
||||
return false
|
||||
|
||||
|
||||
func print_list_animation():
|
||||
for key in animation_object.get_animation_list():
|
||||
print('Anim detected: ', key)
|
||||
|
||||
|
||||
func switch_animation(name:String):
|
||||
#print(">", name)
|
||||
if name != current_anim and animation_object.has_animation(name):
|
||||
current_anim = name
|
||||
animation_object.play( name )
|
||||
animation_object.connect("animation_finished", self._on_AnimationPlayer_animation_finished.bind(name))
|
||||
|
||||
|
||||
func _on_AnimationPlayer_animation_finished(name:String):
|
||||
print("End animation: " , name)
|
||||
|
||||
|
||||
func _init():
|
||||
|
@ -47,6 +88,8 @@ func _init():
|
|||
func _ready():
|
||||
# Place the mouse at the center of the screen
|
||||
get_viewport().warp_mouse(starting_point)
|
||||
search_animation($Mesh/character, "/")
|
||||
print_list_animation()
|
||||
|
||||
|
||||
func _input(event):
|
||||
|
@ -121,7 +164,6 @@ func _input(event):
|
|||
player_rotate_y += TAU
|
||||
camera_rotate_y = player_rotate_y
|
||||
rotate_y( -event.relative.x *0.01 )
|
||||
#$camera_root/horizontal_root.rotate_y( event.relative.x *0.01 )
|
||||
|
||||
|
||||
func _physics_process(delta):
|
||||
|
@ -185,26 +227,50 @@ func _physics_process(delta):
|
|||
if move_strafe:
|
||||
if move_up:
|
||||
speed = SPEED_RUN_UP_STRAFE
|
||||
switch_animation(anim_run)
|
||||
elif move_down:
|
||||
speed = SPEED_RUN_DOWN_STRAFE
|
||||
switch_animation(anim_run_backward)
|
||||
else:
|
||||
speed = SPEED_RUN_STRAFE
|
||||
if input_x > 0.0:
|
||||
switch_animation(anim_strafe_left_walk)
|
||||
else:
|
||||
switch_animation(anim_strafe_right_walk)
|
||||
elif move_up:
|
||||
speed = SPEED_RUN_UP
|
||||
switch_animation(anim_run)
|
||||
else:
|
||||
speed = SPEED_RUN_DOWN
|
||||
if move_down:
|
||||
switch_animation(anim_run_backward)
|
||||
else:
|
||||
switch_animation(anim_idle)
|
||||
else:
|
||||
if move_strafe:
|
||||
if move_up:
|
||||
speed = SPEED_WALK_UP_STRAFE
|
||||
switch_animation(anim_walk)
|
||||
elif move_down:
|
||||
speed = SPEED_WALK_DOWN_STRAFE
|
||||
switch_animation(anim_walk_backward)
|
||||
else:
|
||||
speed = SPEED_WALK_STRAFE
|
||||
if input_x > 0.0:
|
||||
switch_animation(anim_strafe_left_walk)
|
||||
else:
|
||||
switch_animation(anim_strafe_right_walk)
|
||||
elif move_up:
|
||||
speed = SPEED_WALK_UP
|
||||
switch_animation(anim_walk)
|
||||
else:
|
||||
speed = SPEED_WALK_DOWN
|
||||
if move_down:
|
||||
switch_animation(anim_walk_backward)
|
||||
else:
|
||||
switch_animation(anim_idle)
|
||||
if input_x == 0.0 and input_y == 0.0:
|
||||
switch_animation(anim_idle)
|
||||
|
||||
var direction = (transform.basis * Vector3(input_x, 0, input_y)).normalized()
|
||||
if direction:
|
||||
|
|
|
@ -31,4 +31,4 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.55554, 0)
|
|||
transform = Transform3D(-1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 0, 0, -2.14563)
|
||||
|
||||
[node name="Camera3D_FPS" type="Camera3D" parent="camera_root"]
|
||||
transform = Transform3D(-1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 0, 1.49909, 0.0923875)
|
||||
transform = Transform3D(-1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 0, 1.56633, 0.222061)
|
||||
|
|
Loading…
Reference in a new issue