Unity-3D - Can I have several object show the same animation state? - unity3d

An animated figure requires an Animator to have it show animation.
I am trying to create a batalion of soldiers walking in lockstep. Just creating 200 soldiers and moving them is easy, but each one has its own animator and is calculating the animation pose of the soldier in each frame - for each soldier.
But if they are all the same it would seem better to have one animator calculate the pose and use this shaped mesh for all of them.
Is there a way to have several gameobjects share one Animator, one Mesh, and one single copy of the resulting pose?
The screenshot attached shows that the 500 animators consume several milliseconds on 5 CPUs to do the animations...

Related

What is a "Mesh Space Rotation Blend" in "Layered blend per bones" node?

Anim_BP
In the animation blueprint, I use the “Layered blend per bones” nodes to layer two animations together. My character had a running animation and also holds an AK 47. But due to the running animation, the weapon moves jitters a lot when moving left or right. But, this “Mesh Space Rotation Blend” in “Layered blend per bones” node fixes this issue. I am a beginner in Unreal Engine 4 and I follow a series of FPS tutorials from “DevSquad”

How to change game speed in mid development without touching the Timescale in Unity (2D)?

I have a game similar to Sand balls and I was wondering how can I speed up the game a bit without touching the timescale? A nice and somehow correct approach would be to scale down all my objects so gravity can also "affect" the drop movement. I already tested that and works as expected, except I have to apply that for 100+ levels... and would break some prefabs (a mass level editor to scale by bounding box would work but that's another story)
On the other hand, I have timescale but feels like it's the incorrect approach since it also affects animations and leads to unwanted behaviors.
So... do you know any other ways to speed up the game?
If objects is falling down, you can increase gravity. Or without touching timescale, you can just create a public speed multiplier variable and set it to 1 at start.
If you only move balls (Assumed from give sand balls reference), just multiply speed variable of ball with public speed multiplier variable. When you want to change the speed, just change the variable. As an example:
var ballSpeed = baseBallSpeed * speedMultiplier;

Animate gameobject using unity animation with constant speed

I'm animating a object in my scene using the built in gameobject record feature. I add keyframes each 10 second and move my gameobject. Problem is I want the speed to be constant. But since distance between each keyframe is different speed will change.
Is there a automated feature to move keyframes so taht I get constant speed?

How could I create a copy of a gameobject hierachy which mimics all positions, movements, etc of the original? Like a hologram of the original?

I am building a 3d Billiard game in VR using Unity3d.
I try to display a miniature copy of the billiard "table" (actually a cube), like it is at any given moment.
I tried instantiating the root of the billiard hierarchy, just to find out it will instantiate the original gameObject (runnings its Start() methods) which totally makes sense, just not what i am trying to do.
In practice I have a billiard root, which has all the geometry of the table, and all balls as children, those balls can interact physically.
On button press I try to create a hologram of the table, with all its balls at their position at any given time.
So If a player hits a ball and it moves in the original, it should display the same in the miniature.
I thought it might be possible to translate the ball positions (and table rotation etc) every frame to the miniature. but that seams very un optimal.
var midPoint = (leftHand.transform.position + rightHand.transform.position) / 2;
var miniature = Instantiate(gameObject, midPoint, transform.rotation);
miniature.transform.localScale = new Vector3(0.1f, 0.1f, 0.1f);
this obviously does not work as i described above. It creates a completely new instance of the billiard cube. (this code was run from a script inside the billiard root)
The board itself probably doesn't move, so you can just make holograms and simulate the balls.
Since Unity 2018.2, you can create physics scenes and simulate them manually.
For that problem you would need to:
Stop physics simulations.
Physics.autoSimulation = false;
Create a new scene for independent physics simulation.
var physicsPreviewScene = SceneManager.CreateScene("Physics Preview Scene", sceneParams);
Copy the physics-relevant objects and components to the preview scene.
Many ways to do it, but basically colliders, rigidbodies, and for objects you need visuals for, renderers.
You can use caching to avoid creating these every time.
You can also, in theory, have the simulation on the main scene, but then you need to make kinematic all the stuff you don't want simulated, and there are some gotchas.
Then simulate manually.
Get the PhysicsScene from the preview scene: var physicsScene = physicsPreviewScene.GetPhysicsScene();
Simulate: physicsScene.Simulate();
So yea, short of avoiding the components unrelated to physics in the copies, you can't avoid the duplicates; only mitigate their impact with pooling and/or caching.
Another technique is to use casting (spherecasting, in this case) to make a mockup physics simulation, stepping multiple casts with velocity, acceleration (gravity for example) and Time.fixedDeltaTime, and reacting to intercepts/hits as collisions, with Vector3.Reflector something similar. But this will only give you an approximation of how physics would react, and is not going to be an actual (accurate) physics simulation like having multiple PhysicsScenes will.

How to assign 1 animation to multiple objects

I am trying to initiate the movement of two cars in Unity. There will be a variable time gap between the time points which the two cars start moving. But Unity lets me assign only one animation at a time which means that I can not move the second car while the first animation is running.
How do I achieve this?