How to use Humanoid Model : Animator(property) in scripts using Unity Scriptable API - c#

I'm newbie at unity animations and stuff and I want to create a game scene in which at run time I would be able to move a humanoid 3D model and save the movement as an animation (.anim) file.
I may move the parts of the model by mouse or by mapping scrolling bars to animation property values, somehow.
To do all this I decided to go for the animators (properties) of a model. Kindly look at the picture in the link below to know exactly what I am talking about. (Wasn't able to post image since I'm new to stack overflow too)
I searched the unity Scriptable API for this but wasn't able to find the documentation on how to use the above mentioned property directly in your scripts so that animation curves can be generated from them.
Is it possible to do this?
Is there a better way to record animations of humanoid models at runtime (in-game mode) or a better property for humanoid models to use?
Note: The whole animation process is to be handled through code.

Related

How to make soft body (jello) objects or arrays? [duplicate]

I am currently using the NVIDIA FleX package in Unity3D to create soft-bodied, jelly objects. I'm using Unity for animation only, not game dev.
What I am aiming to make is a transparent, jello sphere that retains its spherical shape with elasticity.
The first way I've tried to achieve this is using Flex Array + fluid setting. I've been playing with the settings but I can't get it to remain a sphere, it just becomes a more/less viscous fluid blob.
The second way is using the Flex Soft + fluid setting. It is much better in terms of physics but even with "draw particles" off, but the water droplets are each separated and not one jelly sphere.
This is what it looks like before hitting play, where the left is with Flex Array and the right is Flex Soft. The particles for Array are visible but not for Soft.
This is after hitting play, where the Array becomes one viscous fluid, but not a sphere, and the Soft is very jello-like but the water droplets are all separated.
A solution for either of the two ways would be much appreciated!
the standard approach is to create an Nvidia Flex Controller first...
Then you should also create a Flex Soft Asset...
Then you should create or select a game object and through the Add Component tab in the game object's inspector, find the Flex Soft Actor component [see it loaded up in the image below]...
Ensure your Soft Actor Asset mentioned previously has your required mesh type selected in the inspector option [I chose sphere in the image here] and check to see it looks something like the image below to be sure...
So after that, hopefully, you can just press play and see it in action as it drops and contorts for you.
If not, I have created a quick example for you to download as a unitypackage.
It may still require further resolution with the package manager as the Flex plugin is already inside the package I'm providing here[Using Unity 2020.3.5f1]
Flex in unity package
Anyway, hope this gets you started and somewhere towards your goal with Flex.
As a bonus, I've added a small script to move the flex object as this is outside of the usual approach as we have to call to the NVidia Flex component class of choice and invoke the ApplyImpulse method.
Cheers :)
Edit: There are a small 3 set of tutorials from NV Gameworks on integrating the plugin with Unity and exampling some stuff - this "stuff" is included in my downloadable package provided above.
Here is the youtube link to the 3 set:
Nvidia Gameworks FleX tutorials on Youtube
Edit 2: rereading your question made me think I hadnt really given you the definitive answer as to using a cloth actor and having the mesh renderer deform via the flex cloth deform component.
I am providing another link to another unity package here that will show this in action also allowing you to see the game object and how the cloth component from NVIDIA Flex works with the standard mesh filter and mesh renderer. Hope this more accurately answers your question :)
Example also using Cloth Actors as well as Soft Actors in NVIDIA FleX

How to always get the AR design in front of the spatial walls Unity HoloLens

I am building an app for the HoloLens gen 1 device using Unity 2018.3.13f and MRTK V2 RC1. I got a simple AR design with 2 text objects and 1 rawimage object. After building the project and deploying it to the HoloLens the AR objects ends up behind the spatial mesh (you know all those spatial triangles), but I want all the objects to be in front of the wall.
How do I accomplish this?
The canvas is set to be on the main camera
I have the original settings for the DefaultMixedRealityconfiguraitonProfile if there is something there that needs to be changed.
This is how it looks through the hololens with the app when it does not show the mesh of the wall (sorry for the bad quality)
and this is how it looks when it falls behind the mesh
Do I need to add some mesh renderer or something on the MainCamera to make this possible?
Any help is appreciated, thanks!
I don't believe that the MRTKv2 as of 2019/5/9 has code that will auto-ensure that a specific object is positioned in between the camera and other arbitrary meshes and colliders (i.e. the spatial awareness is one such mesh, though you could imagine just having an arbitrary box or plane in the scene that would occlude that object, in which case, maybe you'd want your "in between" object to stay in between both those two types of potentially occluding things).
There used to be a script in the HTK called Tagalong.cs that would do something like this by doing raycasts from the camera to collidable object:
https://github.com/microsoft/MixedRealityToolkit-Unity/blob/htk_release/Assets/HoloToolkit/Utilities/Scripts/Tagalong.cs
This single large script I think got broken up into smaller scripts (i.e. specific behaviors in the solvers here:)
https://github.com/microsoft/MixedRealityToolkit-Unity/tree/mrtk_release/Assets/MixedRealityToolkit.SDK/Features/Utilities/Solvers
However, from what I can tell, the specific interaction of "keep things automatically between the camera and whatever collidable object" wasn't preserved. Someone else can correct me here if I'm wrong, it looks like this wasn't a behavior that got preserved in V2.
Going forward, there are a couple of possibilities:
1) Probably file an issue on Github here (https://github.com/microsoft/MixedRealityToolkit-Unity/issues) to request this feature be ported over.
2) Use the code in Tagalong.cs to add your own solver that would accomplish this (i.e. the code looks to be all there, there's just some work needed to get done to reorder it to handle what you want)
If you use a sprite renderer, set order in layer (into 0 or -1).
If you use a mesh renderer, try to deactivate dynamic occluded.
Try to change the hierarchy of the sorting layers under Edit-> Project Settings -> Sorting Layers

imported Unity fbx model animation is distorted?

Alright, Ive posted to unity forums too but I usually turn to stack overflow and need to see if anyone else has experienced this problem -
I am working in C# in Unity and we have been importing a maya fbx model with the animations BAKED in on export into the project. We have used the same model for all the animations and just importing separate animated models in because I need to (via animation controller) apply different animations to the same model. Not switch different models in and out.
This was working with different versions of one animation (the idle), but all of a sudden a version of a different animation (on the SAME MODEL, same export settings) when I drag and drop the animation file to the existing model in Unity, the model is distorted playing the animation.
This is what happens - everything actually plays as it did before with other working animations, except the torso is displaced
We;ve checked and none of the keyframes in Maya changed between the 2 models regarding the torso. My question is - has anyone experienced this? Is there a certain setting/box in unity that is preventing 2 animations on the same model from playing without distortion?
What causes distortion of imported animated models?

Finding Main Camera in CustomUnityEditor Class

Iam writing a custom editor script in unity. I want to find the MainCamera in the scene for Custom Editor class so it can be directly assigned to the script and I dont have to assign it. I know i can find all cameras in scene and iterate over it through tags but I want to know if weather a direct method like Camera.main is available which brings the MainCamera of the scene in Custom Editor.
PS: I know it is easy to assign directly but still I want to do it by fetching through in custom editor script. Also I dont want to do it at runtime in start as I have some canvas related calculations which needs to be taken care of
OK I know this is embarrassing but here is the answer which was really simple.
You can directly use the code below to get the main camera.
GameObject.FindGameObjectWithTag("MainCamera").GetComponent<Camera>();
Note:
This will find the first camera with tag like so if your scene has only one main camera then it will get you that and don't have to worry about Camera.main. But my second part of question still remains. When is the Camera.main is assigned?

Animation Controller/Scripting in Unity

I am working on a 2.5D side scroller/platformer project just kind of as a learning experience. I imported a robot model that came with premade animations. I have 2 questions regarding setting him up for movement and his animations. First, I set up movement for x and y, but do I only need to do x? Right now if I hit the UP arrow, the character appears to jump, but feel like that is probably bad form. Am I correct in assuming I should do just the x value for movement and create a separate method for jumping? My second question is with the animation controller. I set up all my states and set my transitions, but I'm not sure what to do from there. What do I do to actually set up the transitions, if anything, and also I could use some information on setting up the animations on the programming side. I have some very slight general knowledge of it, but not much and I'm having trouble finding good solid tutorials for these specific questions.
Thanks for the help!
Yes, I would recommend doing separate controllers and script files for side to side moving and jumping. That way if you ever need to change one of those behaviours you have a specialized place to do it. Also, perhaps you have an enemy that moves side to side but doesn't jump. Or perhaps something that jumps but doesn't move. You could just drag the correct behaviour onto the game object.
as for animations, the unity learn tutorials are pretty helpful getting you started on animations and very basic state transitions

Categories