T
T
Tacker2022-02-18 21:10:09
Unity
Tacker, 2022-02-18 21:10:09

How to animate an object through code?

I need to make an animation for an object so that the object moves along one axis (y). The fact is that I have several objects that should have animation (up, down) smoothly. When animating through Unity animation, all objects move to the same point. In short, I need to make sure that all objects move smoothly up and down at the same time and that they are in different places. How to do it?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
G
GFX Data, 2022-02-18
@Tacker

DOTween asset:

float upY = 5f;
float time = 2f;
transform.DOMoveY(upY, time).SetLoops(-1, LoopType.Yoyo);

F
freeExec, 2022-02-18
@freeExec

void Update() => transform.Translate(Vector3.up * Time.deltaTime * 0.001);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question