How to render animated models via scripts when using Graphics.Drawmesh ?

Hey there !

A few friends and I are making a game for our student project, and in this game one of the biggest challenges we’re going to face is the management and rendering of hundreds of simple, yet numerous entities on screen. The other big challenges I shall speak about in other threads…

So, here’s the thing : currently we have a system of “Entities”, and the goal is to render these entities going completely around Unity’s Gameobject and Component system because we believe it’s not efficient, not even made for that kind of application. We’ll use it for other objects, notably magic missiles, the player characters themselves, and some other things, but back to the matter at hand.

For now, some of the entities we call “DrawableEntities” have an integer attribute that corresponds to an ID within an array of objects we call “Models”. Each model has a mesh assigned to it, and a bunch of animations sorted in a very specific order (animations[0] = idling animation, animations[1] = moving forward animation…) that are used by the renderer when it knows there is, for example, an entity at position 0,0,0 with model ID 1 currently playing his idling animation. The Model object also knows about LOD models which the renderer use automatically depending on the entity’s size, how far it is and the amount of LOD models the entity possesses (the more of them, the further away the entity can be seen from).

We believe this is a good system, because it limits the amount of data we need per entity, and also it works very well with a central server - multiple clients based system, where the server only knows about the entitiy’s data and the client does the link between the model ID he receives for each entity and the models it knows about.

However, I have ran into a problem. Currently, to render an entity’s model, I use Graphics.drawmesh, and it works very well for static models. However, I have found no way to “technically” render animations for such models.

I have thought about two solutions :

Having the DrawableEntity object communicate about its current animation and its current frame, and using the bone deformation data on the model, the current animation and the current frame, create a model “on the fly” and use it to render the entity on each frame.

Or, whenever the models are loaded, also make them load a bunch of “animation models” (by using the BakeMesh() method of the SkinnedMeshRenderer class) that the renderer then automatically chains together to form “animations” that are in reality only a chain of static meshes.

I have found no way to achieve any of these solutions, and it worries me because without animations, obviously, the game won’t look that good :stuck_out_tongue:

So I call on you guys for ANY help, insight, ideas… that could help me solve this problem. I’d be much obliged.

Thanks a thousand times like we say in france.

Up.