cria um controle de personagem 3d terceira pessoa ...
Créé le : 23 juin 2026
Créé le : 23 juin 2026
cria um controle de personagem 3d terceira pessoa godot com personagem estilo anime
A seguir está um guia completo em português (Godot 4.x) para criar um controller de personagem 3D em terceira pessoa com um personagem de estilo anime – da configuração da cena ao script de movimentação, câmera e animações.
| Item | Detalhes |
|---|---|
| Godot Engine | Versão 4.x (Mono ou padrão) |
| Modelo Anime | FBX/GLTF com esqueleto humanoide e animações (Idle, Walk, Run, Jump, Fall) |
| Texturas Toon | Sombreamento 1-4 tons + contorno (edge outline) opcional |
| Conhecimento Básico | Navegação no editor, criação de nós, InputMap, AnimationTree |
Project ‣ Project Settings ‣ Input Map)| Ação | Teclas / Botões |
|---|---|
move_forward | W / ↑ |
move_back | S / ↓ |
move_left | A / ← |
move_right | D / → |
jump | Space / A (Gamepad) |
sprint | Shift / B (Gamepad) |
camera_rotate | Botão direito do mouse |
camera_scroll | Wheel Up/Down |
textCharacterBody3D (renomeie para Player) ├─ Skeleton3D # Esqueleto importado ├─ MeshInstance3D # Malha anime ├─ AnimationTree # Grafos de animação (modo State Machine) ├─ SpringArm3D # Mantém a câmera atrás │ └─ Camera3D └─ (opcional) OutlineMesh # Para contorno estilo anime
SpringArm3D.length ≈ 4 m, Collision Mask vazio (ou só ambiente).Crie res://scripts/player_controller.gd e anexe ao nó Player.
gdscript# player_controller.gd extends CharacterBody3D @export var walk_speed : float = 6.0 @export var sprint_mult : float = 1.6 @export var jump_velocity : float = 4.5 @export var mouse_sens : float = 0.12 @export var pitch_min : float = -45 @export var pitch_max : float = 60 @onready var cam_target : Node3D = $SpringArm3D @onready var camera : Camera3D = $SpringArm3D/Camera3D @onready var anim_tree : AnimationTree = $AnimationTree @onready var state = anim_tree.get("parameters/playback") var yaw : float = 0 var pitch : float = 10 # ligeiramente para baixo func _ready(): Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED) anim_tree.active = true func _unhandled_input(event): if event is InputEventMouseMotion and Input.is_action_pressed("camera_rotate"): yaw -= event.relative.x * mouse_sens pitch -= event.relative.y * mouse_sens pitch = clamp(pitch, deg_to_rad(pitch_min), deg_to_rad(pitch_max)) cam_target.rotation = Vector3(pitch, yaw, 0) # Libera o mouse com Esc if event.is_action_pressed("ui_cancel"): Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE) func _physics_process(delta): # Direções relativas à câmera var forward = -cam_target.transform.basis.z var right = cam_target.transform.basis.x var dir = Vector3.ZERO if Input.is_action_pressed("move_forward"): dir += forward if Input.is_action_pressed("move_back"): dir -= forward if Input.is_action_pressed("move_right"): dir += right if Input.is_action_pressed("move_left"): dir -= right dir = dir.normalized() # Velocidade var speed = walk_speed if Input.is_action_pressed("sprint"): speed *= sprint_mult velocity.x = dir.x * speed velocity.z = dir.z * speed # Gravidade / pulo if not is_on_floor(): velocity.y -= ProjectSettings.get_setting("physics/3d/default_gravity") * delta elif Input.is_action_just_pressed("jump"): velocity.y = jump_velocity move_and_slide() # Gira o personagem para onde está andando if dir.length() > 0.05: var target_yaw = atan2(-dir.x, -dir.z) rotation.y = lerp_angle(rotation.y, target_yaw, delta * 10) _update_animation(dir) func _update_animation(dir: Vector3): if not is_on_floor(): state.travel(velocity.y > 0 ? "Jump" : "Fall") return if dir.length() < 0.05: state.travel("Idle") else: state.travel(Input.is_action_pressed("sprint") ? "Run" : "Walk")
Se quiser um script separado no SpringArm3D para zoom:
gdscript# spring_arm_zoom.gd extends SpringArm3D @export var min_len := 2.5 @export var max_len := 6.0 @export var scroll_speed := 0.5 func _unhandled_input(event): if event is InputEventMouseButton and event.is_pressed(): if event.button_index == MOUSE_WHEEL_UP: length = max(length - scroll_speed, min_len) elif event.button_index == MOUSE_WHEEL_DOWN: length = min(length + scroll_speed, max_len)
Idle, Walk, Run, Jump, Fall._update_animation via state.travel("Nome") troca os estados.| Recurso | Como aplicar |
|---|---|
| Shader Toon | Use ToonShader oficial (Godot 4 sample) ou crie material com rim & step(vec3) para sombras em degraus. |
| Contorno (Edge Outline) | a) Duplicar malha, inverter Scale = -1 no eixo X, ativar Flip Faces, aplicar material preto opaco. b) Ou use Screen-Space Outline no render pass. |
| Olhos/Expressões | Texturas multi-sprite em UV ega ou BlendShapes. |
| Efeitos | Partículas stylized para passos/pó, Bloom e Color Grading no WorldEnvironment. |
move_and_slide() em vez de move_and_collide() para suavidade com gravidade.SpringArm3D.collision_mask para evitar que a câmera atravesse paredes.CharacterBody3D por MultiplayerSpawner + CharacterBody3D e sincronize velocity/transform.ConfigFile ou AutoLoad para trocar entre “Controle Souls-like” e “Controle MMO” sem mexer no script.Com a cena configurada, o personagem pode:
Isso serve como base; basta substituir o modelo ou ajustar parâmetros para refinar seu jogo de terceira pessoa em Godot 4!