0 votes

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))
in Engine by (81 points)

I guess you need AnimationTreePlayer.
https://www.youtube.com/watch?v=3xxUt3iABgA
This might help.

3 Answers

0 votes

Well after days of frustration, I've solved by problem with coding. However I can say that yes you can play multiple animations at once with animationtreeplayer, it was wasn't what I was looking for. animationtreeplayer is very helpful if you want to switch from animation to animation very nicely. but not play four animations at once the way I wanted. if you want to how I did it with code go here.

http://www.godotengine.org/qa/3678/moving-camera-for-3rd-person-spaceship

by (81 points)
0 votes

Did you try using the tween class?

I use it for all things camera wise and it it works like a charm.

by (196 points)
+2 votes

Hi,
I have just used a second animation player in the tree to solve this (2D) :)
Greets

by (26 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.