Play multiple animations of same object at the same time - animation

I'm using a json file with one object exported from blender with 2 animations (example: walk and lift_arm). I can play animations as single and also the 2 together. That's OK, but when they play together (at the same time after doing anim1.play() and anim2.play()) it seems only half of each is played as if the time line would be run twice the speed. Why does it happen?

Related

How do I programmatically load animations in Godot, separating animation from armature/skeleton?

I'm trying to load 3D animations separately from the 3D armature that will be using the animation.
I can import animations from 3d formats (.gltf, .escn) and generate Godot animation files by setting the Animation->Storage option to either ".anim" or ".tres".
How do I load one of those files (.anim, .tres) into an AnimationPlayer (or equivalent) from a GD script at runtime?
My ultimate goal is character customization. Different parts are assembled to compose a standard armature/skeleton, and the animation is loaded on top at runtime. However, I would like different animations under standard names. Like different "walk" cycles for different styles of character (the cloaked mage walks differently than the armored knight), but the code should just read something like:
$AnimationPlayer.play("walk")
I shy away from procedural animation because of the performance hit. There may be hundreds of characters on-scene at one time.
You can load the animations you saved (E.g. from the animation panel, Animation -> Save as) and from GDScript load them with load and then call add_animation on the AnimationPlayer passing the the name and the loaded resource as parameters:
AnimationPlayer.add_animation("Walk", load("res://animations/walk.tres"))

Define timeframe for animation in KML

Is there any possibility to define a timewindow for an animation of KML objects? Like if i have to occurences animated (polygon 1 appears on the 1/1/2018 and polygon 2 on the 6/10/2018). Is there any way to define that the whole animation should last for f.e. 30 or 45 seconds? I only see that Google Earth always interpolates the animation time depending on the given
<TimeSpan> <begin> 2004-03 </begin> <end>2004-04</end></TimeSpan>
dates of the document.
In the current Google Earth Pro interface, there is no way to specify the duration (in playback-time) of an animation like this. As you noted, it expands the time slider to include the dates & times from all loaded KMLs, and plays across the slider at a preset speed (adjustable in the slider settings).
One way you could apply time playback with precise control is to set up a KML Tour which animates between two views (with time tags applied), over a specific number of seconds. Then you could have your user play it back using the Tour interface instead, and see the timing you want. Unfortunately KML Touring is rather complex with a long learning curve. There are simple things you can do (possibly including something like your request) using the tour recording interfaces in Earth Pro, but to really harness the full power of touring you'll need to create custom KML code, so consider yourself warned. :-)

The render loop freezes temporarly at first "contact" of the camera frustum with multiple meshes

I have a basic scene into wich I am loading objects using the JSONLoader. The objects themselves have very small footprint, for example: milk carton: 560kb with textures, 34 kb json file.
When rendering, let's say 10 new objects, if I orbit the camera to bring them into view, the animation loop freezes for a second or so. After this first freeze, the camera orbits smoothly no matter how many objects. Loading dynamically the objects would be a solution, but for my specific use case, I still need to load at least 50 objects at first load.
Update - I have added the preload functions I use in my production project, and I also added 21 different models just to illustrate my specific scenario. I have tried the following solution:
preloading the json files,
reading the source path to the textures,
loading them with texture loader,
overwritting the maps of the json material objects with the preloaded textures,
finally releasing the objects into scene. The same behavior occurs again.
Try to click the setCamera link to se how laggy it is. I need to cut this lag to 0ms. Thanks for support!
Working demo: http://demo.adrianmoisa.ro/flexikom-loader/ First try to orbit the camera up and down to check it's working ok, then left and right. Any advice is much appreciated!
Looking at your code I see you are loading the same object 10 times, creating 10 meshes that are all the same. All use the same geometry and the same material. This is where your lag comes from. Both from the loading (asynchronous request to the server) and the object creation.
What you need to do is to load one object and create one material that you will assign to the object. Then you clone() the object 10 times assigning the different position that you want to each cloned object.
Gaitat is correct that you should not be loading the same object 10 times. But I think the lag is directly related to the textures.
You should load the textures outside of the loop.
How it is now, you are loading 30 textures onto the gpu when you could be just loading 2 (at least I think this is how it is working).
Profiling the page shows that texture2D is taking a lot of time.
I am almost certain that this will stop the lag.

How to control speed of animation on Unity by a .txt file?

I am trying to controlling the flow of an 3D animation on unity through the sound.
Therefore, through a synthesizer sounds, get the BPM of a song, which are stored in a file. Txt, with the given time and the number of BPM in second. Then in Unity, I have a pre-defined animation, and already carry the file with the information of BPM, but now I do not know how I can make the animation speed is controlled by the information in that file.
Any idea?
You can always change AnimationState.speed to serve that purpose.
http://docs.unity3d.com/ScriptReference/AnimationState-speed.html

same animation on the screen multiple times (cocos2d)

I would like to add the same sprite animation multiple times. I've tried it with a loop. When I run the project on iPhone Simulator it tells me that I've already added this child. The sprite animations code is here: http://getsetgames.com/2010/04/18/how-to-animate-sprites-in-cocos2d/
If you try to add the same pointer more than once it doesn't like it. Just create multiple animations (therefore multiple pointers). You can just make a copy of the same animation multiple times if you like. You may also need to create new CCSprite pointers too depending on your methods. That's all it is though really. It already has the object (the point) so it won't take it again.

Resources