Hi! I’m experimenting with animation of GameObjects that are children of a canvas, and i noticed some interesting things.
My goal is to combine tween.js animations with Unity-exported animations.
So Let’s say, i have the following structure in Editor:
Canvas
- Container
- - image1
- - image2
The idea is to have image1 and image2 to be animated inside Unity and exported using AnimatorComponent (I use the animator window to add the keyframes on the GameObjects themselves). Then, in runtime, the Container have a simple scale animation using tween.js. So far, the last one works fine, but the animation on the images are not being played.
Since I allready worked with skinned meshes and have no issues, is it posible that this is a support issue? Is there some sort of specific setup that needs to be there in order for the animation to play? Wouldn’t the usage of both at the same time create conflicts? (Specifically since they’re both updating scales).
Thank you very much in advance
Edit: Unity Editor version is 2022.3.4f1 and Needle Engine version is 3.47.6. OS: Windows 10.
Hi whtw4thewin! I’m an AI-powered assistant here to help you. I can’t answer your question directly, but I can assist you with queries about Needle Engine, three.js, and basic Unity or Blender help. Please reply with more details, such as your OS and the versions of Needle Engine, Unity, or Blender you are using, and I’ll do my best to assist!
2 replies left - GPT 4O thread_9tcETG35ZO6DKhyrrJ7pbQe9 Reply to this message to continue the conversation
Thank you for the details, whtw4thewin! When combining tween.js animations with Unity-exported animations, there are a few considerations to ensure that both animations work harmoniously:
Animator Component: Ensure that the AnimatorComponent is correctly attached to both image1 and image2. Make sure the animation controller is set up correctly and that the animations are included.
Animation Conflicts: Since both the Unity animations and tween.js affect the scale, conflicts may arise. To avoid this, consider animating other properties instead of scale with tween.js, or selectively disable the scale animation in the Unity Animator when tween.js is active.
Update Order: Confirm that the update order of animations does not conflict. You might need to adjust the timing or the frames to allow both animations to play without overriding one another.
Debugging: Utilize the Unity console to check for any errors or warnings related to the Animator. It may provide insight into why the animations are not playing.
Feel free to explore these areas; if you have specific code snippets or further issues, please share them for more detailed assistance!
1 replies left - GPT 4O thread_9tcETG35ZO6DKhyrrJ7pbQe9 Reply to this message to continue the conversation
So, in the first try i attached the Animator component to the object that is being animated and it works just fine. In the second one, I attached it to the inmediate parent, the idea is to animate 2 images, so i thought that i could just reference its properties from the parent object directly, however looks like this approach does not work.
Final result is that Test1 works as expected, but Test2 does not work. Structure is the same for both as you can see in the captures.
Note: Im assigning tweenContainer through the Editor, but it is not necessary, originally i wanted to reference objects outside the one that contains this script, so i just left it here.
mmm, there is a couple of errors, but they are the same for both elements.
First, I´m using position instead of anchoring position, (this is because recording only detects changes on position, while anchored position remains at 0).
The image on Test1 looks like this:
I interpreted that by It is required to animate the whole vector... you mean all properties of position / anchored position / scale and so on.
No, as you can see on my screenshot, i only animated the anchorPosition.x and that would lead to the warning. the animation needs to animate both X and Y.
You seem to have it correctly, the NullReferenceException is definitely wrong and could lead to unexpected exports.
The exception was caused by animating this property (highlighted in blue):
Removing it from the anim makes the scene to work. Could you confirm that?
I’m bit puzzled why the renaming worked for you. Perhaps you also clean the anim?
AhĂ , found it, i can confirm that indeed, removing that property solves the issue, and also found an interesting behaviour:
The error happends when using add Property button from the Animation window or when using right clic > add key on the pos X or pos Y inspector properties while on preview mode, since Unity inserts what it looks like an empty floating number instead of a complete vector value.
It fixes itself by inserting an additional keyframe in recording mode (after translation) or by adding a keyframe from the Pos Z property on inspector.
So apparently it happends if you ignore it by accident since apparently Unity does not distinguish between position and anchored position in those two cases.
Some observations:
Using right clic + add keyframe on Pos X and then doing the same on Pos Y adds a full anchored position vector.
Inserting anchored position trough the Add property button from the animation window also inserts a fully functional keyframe.
Using the Add Property button to add position property results in the same error case.
These are the only cases where this happens, i went through all the other properties from Rect transform and there were no problems, those where the only cases where this behaviour occurs.