3d Animation Question

Discuss modding questions and implementation details.
Post Reply
l3lessed
Posts: 1400
Joined: Mon Aug 12, 2019 4:32 pm
Contact:

3d Animation Question

Post by l3lessed »

So, I'm working on setting up proper animations for the 3d models on the script side of it; We will need to be able to control multiple animations via scripts to create realistic moving models, so I began working on this. Before I dump tons of time into this, I want to check I even need to do this to get the precompiled prefab animations to play.

After trying to import animations a number of different ways, I found the recommendation is to use a animator controller for each model type. I don't mind trying to set this up myself, as I believe it will also affect how the script works, but before I do, is this the correct way, as I am seeing online every where?

Video of how this process works


Unity documentation on the process
https://learn.unity.com/tutorial/contro ... 002053b4e2

I'll probably take a break and work on roaming and pathfinding coding more. I'm getting to the point with animations and the bug with certain animal models not properly applying the new random textures to all of those models in the cell that I need to focus on something else and let this process more.
My Daggerfall Mod Github: l3lessed DFU Mod Github

My Beth Mods: l3lessed Nexus Page

Daggerfall Unity mods: Combat Overhaul Mod

Enjoy the free work I'm doing? Consider lending your support.

l3lessed
Posts: 1400
Joined: Mon Aug 12, 2019 4:32 pm
Contact:

Re: 3d Animation Question

Post by l3lessed »

This has been solved.

The key is to ensure you attach an animation object to the prefab that has the connected animation armature. Then, add each unique animation armature to the new animation object, until the new animation object list on the prefab is populated with all the unique animations for that prefabbed model.

At that point, use the PrefabObject.GetComponent<Animation>();
Then, merely use the new animation object you grabbed and stored to play and manipulate the animation how you wish.

Code: Select all

//grab the prefabbed animation object from the prefab at runtime. I do this on the start sequence of the script.
void Start()
{
	Animation prefabAnimationObject = PrefabObject.GetComponent<Animation>();
}

//check if the animation object is playing anything at all. If not, do this.
if(!prefabAnimationObjec.IsPlaying())
{
	//begin blending the main idle animation, and set its weight to 90% so it operates as the base animation since it has heighest weighted value.
	prefabAnimationObject.Blend("idle_animation", .9f)

	//begin blending the tail swoosh animation, and set its weight to between 15% and 40% so blends into the base animation as a subtle but dynamic tail swoosh.
	prefabAnimationObject.Blend("idle_tail_Animation", Random.Range(.15f, .4f))

	//begin blending in a random idle animation, and set its weight between 25% and 50% of the animations playingo blends into the base animation and tail animation dynamically.
	prefabAnimationObject.Blend(AnimationList[idleAnimationList[Random.Range(0,idleAnimationList.Length)]], Random.Range(.25f, .5f))
}	
My Daggerfall Mod Github: l3lessed DFU Mod Github

My Beth Mods: l3lessed Nexus Page

Daggerfall Unity mods: Combat Overhaul Mod

Enjoy the free work I'm doing? Consider lending your support.

Post Reply