I understand that there is an Animation Editor with keyframes and such, but I was wondering if I can use code to animate objects. For example: Move Scale Color Call functions * Sequence of animations

@Megalomaniak said: Um, sure. Procedural animation is a thing. Though generally using animation blending/layering and pre-created animation clips will give better results. Depends on what exactly you are after.

https://www.alanzucconi.com/2017/04/17/procedural-animations/ (unity examples)

This seems much more complicated than what I'm asking for. What I want for example is simply to move an object from point A to point B but those points will be determined during runtime. And after that, I would like to do another animation like scaling the object and then call a certain function.

PS: Without using physics, lerp or coroutine. I'm talking about an "Animation" library.

@Abdo23 said:

PS: Without using physics, lerp or coroutine.

:/ Not really sure how to respond to that. Not even lerp? Does Tween count?

(note that this video is a bit old and makes use of godot 2.x)

@Abdo23 said:

@Megalomaniak said: Um, sure. Procedural animation is a thing. Though generally using animation blending/layering and pre-created animation clips will give better results. Depends on what exactly you are after.

https://www.alanzucconi.com/2017/04/17/procedural-animations/ (unity examples)

This seems much more complicated than what I'm asking for. What I want for example is simply to move an object from point A to point B but those points will be determined during runtime. And after that, I would like to do another animation like scaling the object and then call a certain function.

PS: Without using physics, lerp or coroutine. I'm talking about an "Animation" library.

Something like this, for example? (not tested, just an example)

extends Spatial

var anim_position_one = Vector3(0,0,0)
var anim_position_two = Vector3(0,0,0)
var anim_position_delta = Vector3(0,0,0)
var anim_position_percent = 0;
var anim_position_start = false
var anim_position_speed = 4;

func _ready:
	start_animation(get_node("Node_01").global_transform.origin, get_node("Node_02").global_transform.origin)

func start_animation(position_one, position_two):
	anim_position_one = position_one
	anim_position_two = position_two
	anim_position_delta = anim_position_two - anim_position_one;
	anim_position_percent = 0
	anim_position_start = true

func _process(delta):
	if (anim_position_start == true):
		anim_position_percent += delta * anim_position_speed
		if (anim_position_percent >= 1):
			end_animation()
			anim_position_percent = 1
			anim_position_start = false
		global_transform.origin = anim_position_one + (anim_position_delta * anim)

func end_animation():
	print ("Animation ended! Do whatever you need to do when the animation stopped here!")

Then you can pass in different positions into start_animation to change how the animation works. Granted, this is basically already what the Tween function does, but instead you are just making the functionality Tween provides yourself.

I've done code similar to this before when I am rapidly prototyping and I need to have more than one property change as the values change from one thing to another. However, a huge problem with code like this is it gets very messy. Each animation you want to have in code you will have to write the code to run it, and depending on how many animations you have, this can get overwhelming and complex in a very short time.

If you can, I would highly suggest using the AnimationPlayer node when possible. You can add function tracks to call functions when the animation ends. It is a little harder if you want to smoothly move from one changing point to another changing point, but in that case I would just use the Tween function, as that is what it's meant to do.

By using the AnimationPlayer node for your non-changing parts of your animation(s), and the Tween function for your changing ones, you can pretty much handle any animation simply by combining these together in various ways. For example, you can start function that will Tween the positions in _physics_process at the end of an animation in the AnimationPlayer node.

Hopefully this helps! :smile:

@Megalomaniak said:

@Abdo23 said:

PS: Without using physics, lerp or coroutine.

:/ Not really sure how to respond to that. Not even lerp? Does Tween count?

Yes, this Tween "Library" is similar to what I'm looking for. I understand that under the hood "Tween" uses some sort of lerp or coroutine, update or a combination of them, but what I wanted is a library that does all the heavy lifting for me. Example 1, Example 2

I checked the docs. for "Tween" but there are some functions that aren't clear. The very first function is called: "bool follow_method" and here is description: "Follows method of object and applies the returned value on target_method of target, beginning from initial_val for duration seconds, delay later. Methods are called with consecutive values." What does that even mean? and there are others that I also didn't understand. And also can I make a sequence of actions linked together?