Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | 1997 | |
Old Version | Published before Godot 3 was released. |
I’m trying to animate my spaceship’s 3rd person camera similar to this.
( https://www.youtube.com/watch?v=ijh-n-ntImA ) however the animations only play one at a time so it ends up looking very choppy. there are four animations for up, down, left and right which just move the camera a bit in those directions. I need to get the animations to blend with each other(for example up and left at the same time), and when when the ship stops turning have the camera smoothly slide back.
this is the code for the movement part.
extends RigidBody
var speed = 1
var isshooting = false
var laserCount = 0
var laser = preload("res://assests/models/laser/laser.scn")
var laserArray = []
var up = false
var down = false
var left = false
var right = false
func _ready():
set_fixed_process(true)
set_gravity_scale(0)
func _fixed_process(delta):
if Input.is_action_pressed("ui_accelerat"):
speed = speed + .1
if Input.is_action_pressed("ui_decelerate"):
speed = speed - .1
if Input.is_action_pressed("ui_up"):
get_node("Ship").rotate_x(delta/.8)
if up == false:
get_node("Ship/Camera/AnimationPlayer").play("up")
up = true
else:
up = false
if Input.is_action_pressed("ui_down"):
get_node("Ship").rotate_x(-delta/.8)
if down == false:
get_node("Ship/Camera/AnimationPlayer").play("down")
down = true
else:
down = false
if Input.is_action_pressed("ui_left"):
get_node("Ship").rotate_z(delta/.7)
if left == false:
get_node("Ship/Camera/AnimationPlayer").play("left")
left = true
else:
left = false
if Input.is_action_pressed("ui_right"):
get_node("Ship").rotate_z(-delta/.7)
if right == false:
get_node("Ship/Camera/AnimationPlayer").play("right")
right = true
else:
right = false
if speed > 10:
speed = 10
get_node("Ship").translate(Vector3(0,0,delta*speed))
I guess you need AnimationTreePlayer
.
https://www.youtube.com/watch?v=3xxUt3iABgA
This might help.
volzhs | 2016-05-06 18:58