-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
A 3D character walking in a world using Godot #62
Comments
For example, I have imported from Mixamo this walking animation: Screencast.from.14-10-22.00.10.50.webmThe animation is a complete cycle of the two steps, the basic animation for walking. And it has the animation for the parts but also the movement of the character. So it is fully done. What is pending? To redo the animation starting from the last point the character was. And to use the keys, you can start, stop the animation from the last status of it. Let's try to implement with GDScript:
|
Once we have ended playing with the Mixamo animation, the goal is to create our own with totally free models, and doing the animation from scratch, which is not something easy. |
Ok, things progressing as expected: Screencast.from.14-10-22.19.11.14.webmJust needed a bit of GDScript to make the two steps animation to become a real walking: extends Node3D
const step_distance = 1.5
# Called when the node enters the scene tree for the first time.
func _ready():
var boy_anim_old = $AnimationPlayer.get_animation("Armature|mixamocom|Layer0")
boy_anim_old.set_loop_mode(0)
# $AnimationPlayer.add_animation("move_new", boy_anim)
$AnimationPlayer.play("Armature|mixamocom|Layer0")
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
if !$AnimationPlayer.is_playing():
var pos = $Armature.get_global_position()
var new_pos = Vector3(pos.x, pos.y, pos.z + step_distance)
$Armature.set_position(new_pos)
$AnimationPlayer.play("Armature|mixamocom|Layer0")
|
Next natural step is howto combine transformations. Probably if all the animations has a rest pose we can start from it to change between animations. But the idea is to have several animations sharing the same skeleton. Not sure if this could be possible with Mixamo in its free version. And yes, it is possible at least in Blender: |
The GDScript for Godot 3.5.1: extends Spatial
const step_distance = 1.5
# Called when the node enters the scene tree for the first time.
func _ready():
var _anims = $AnimationPlayer.get_animation_list();
var boy_anim_old = $AnimationPlayer.get_animation("Armature|mixamocom|Layer0")
var boy_anim = Animation.new()
boy_anim_old.loop = 0
# $AnimationPlayer.add_animation("move_new", boy_anim)
$AnimationPlayer.play("Armature|mixamocom|Layer0")
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
if !$AnimationPlayer.is_playing():
var pos = $Armature.get_global_translation()
var new_pos = Vector3(pos.x, pos.y, pos.z + step_distance)
$Armature.set_global_translation(new_pos)
$AnimationPlayer.play("Armature|mixamocom|Layer0") |
Ok, my last approach is using the Mixamo animation in place (no displacement) and using this code: extends Node3D
const step_distance = 0.015
func _ready():
$AnimationPlayer.play('Armature|mixamocom|Layer0') # Replace with function body.
func _process(delta):
var pos = $Armature.get_global_position()
var new_pos = Vector3(pos.x, pos.y, pos.z + step_distance)
$Armature.set_position(new_pos)
func _on_animation_player_animation_finished(anim_name):
$AnimationPlayer.play("Armature|mixamocom|Layer0") |
Ok, the goal of this task is to have this character, but created from scratch and rigging and animated later by us. So we can show the full process. Using the Mixamo model is cool for a quick demo and for playing with the animation in Godot. It is time to do the same with our own model. Go go! But this will be done in #69 so it is time to close this ticket! |
There are several strategies for implementing the 3D character walking. Some quick ideas:
Both animations must be synced. If the walking stop, the step animation stop. The step animation must continue from the last point.
There are other details like howto animate the changes of directions when walking. But let's go step by step 😄
The real work will be done in #69
The text was updated successfully, but these errors were encountered: