Godot Version
4.7 stable
Question
I’m a big noob and i have been trying to make an active rag-doll character. I’m stuck on trying to give him animations. I want it to function similar to TABS but i don’t know how to do that and i can’t find any tutorials online. Until now i tried following this one https://youtu.be/rk-ngRJDhsA and this one https://youtu.be/VRXHzTUe1-Y. Any ideas how i do that?
my code for the character:
extends Node3D
@onready var BodyControl = $BodyControl
@onready var LeftLegControl = $LeftLegControl
@onready var RightLegControl = $RightLegControl
@onready var LeftArmControl = $LeftArmControl
@onready var RightArmControl = $RightArmControl
@onready var animation_player: AnimationPlayer = $AnimationPlayer
@onready var CameraPivot = $CameraPivot
@onready var Head = $"Armature/Skeleton3D/PhysicalBoneSimulator3D/Physical Bone spine2"
@onready var Body = $"Armature/Skeleton3D/PhysicalBoneSimulator3D/Physical Bone spine2"
var Mouse_sensitivity = 0.3
var WalkSpeed = 100
var Damping = 0.9
var current_delta:float
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
$Armature/Skeleton3D/PhysicalBoneSimulator3D.physical_bones_start_simulation()
#animation_player.play("character_model_anim/walking")
func HandleWalk(delta):
var direction := Vector3.ZERO
if Input.is_action_pressed("forward"):
direction -= BodyControl.transform.basis.z
if Input.is_action_pressed("backward"):
direction += BodyControl.transform.basis.z
if Input.is_action_pressed("left"):
direction -= BodyControl.transform.basis.x
if Input.is_action_pressed("right"):
direction += BodyControl.transform.basis.x
direction = direction.normalized()
Body.linear_velocity += direction*WalkSpeed*delta
Body.linear_velocity *= Vector3(Damping,1,Damping)# add damping to make it less slippery
func HandleRotation():
BodyControl.rotation.y = CameraPivot.rotation.y
LeftLegControl.rotation.y = CameraPivot.rotation.y
RightLegControl.rotation.y = CameraPivot.rotation.y
LeftArmControl.rotation.y = CameraPivot.rotation.y
RightArmControl.rotation.y = CameraPivot.rotation.y
func _process(_delta):
CameraPivot.global_transform.origin = Head.global_transform.origin
HandleRotation()
func _physics_process(delta):
HandleWalk(delta)
func _input(event):
if Input.is_action_just_pressed("left_mouse"):
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
if Input.is_action_just_pressed("ui_cancel"):
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
if event is InputEventMouseMotion:
CameraPivot.rotation_degrees.y -= event.relative.x * Mouse_sensitivity
CameraPivot.rotation_degrees.x -= event.relative.y * Mouse_sensitivity
CameraPivot.rotation_degrees.x = clamp(CameraPivot.rotation_degrees.x,-90, 90)