Y
Y
Yura Mailler2021-07-11 10:48:13
Unity
Yura Mailler, 2021-07-11 10:48:13

Is it possible to turn on the animation of another object from the script of one object?

Hello! I have two objects , one player and another item and the player can interact with the item . And in the code of the item, I wrote functions when the buttons are pressed, when the buttons are pressed, the player releases or raises the item, the lifting should go with animation, the animation starts when the button is pressed, but because animations are made for the player, not for the subject, it gives an error. Well, the question is whether it is possible to turn on the animation of another object from the script of one object? I know that it is possible to run the animation through the code of the player itself, but then I will have to pass some parameters through GetComponet, but it hurts the optimization.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
AnanasikDev, 2021-07-11
@Yura111

Picking up an item is best done in the player's script. So it will be more readable, and the problem will be solved.
Well, the animations of another object are indeed called through GetComponent.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question