Unity 3D and Mixamo Animation -- Feet Inside of ground - animation

I have a weird problem I can't figure out. I'm new enough to Unity 3D I have a hard time even posing the questions sometimes.
Take a careful look at this picture where I drew the red circles:
The problem is that both in the actual game and in the animation preview, this Mixamo character, using the Mixamo running animation, shows her feet under the ground. Actually, this is a problem with all animations. She does NOT start out under the ground (and in fact starts above ground.) But when the game runs, she falls to the ground (well, she doesn't really fall since she has no ridge body. She appears suddenly at level 0, which you'd think is right on the ground, but in fact it shows her a foot or two under the ground), and the animation then plays with her too low. She doesn't have a ridged body, so that is not the problem.
You can also see my settings for the animation. I've played around with all of them and can't fix it. This happens whether or not I apply root motion or foot IK.
Is there a way to 'lift' the animation up so that it is right on the ground?

I just found an issue in Unity. When i kept the T-Pose Model (Skinned) in a folder and the animation of it in another folder then the Animations turn out to misbehave. Like Legs twitching or parts of body going down. When I brought the T-Pose and other animations together in one folder and updated the reference in Rig of T-Pose then all became normal.

One shitty basic problem is just:
There's an obscure setting actually on "Layers" in Animator, on the "base" layer you have to explicitly turn on "IK Pass".
Only in very unusual situations would you want this "off", just another bizarre mistake by Unity.

Reimporting fixed the problem. I do not know why. It seems that when you play with the animations, they sometimes get corrupted.

Related

How do I put a camera on a separate window without lag?

The current way I'm doing it works, but is really heavy on performance, and I'd like to reduce the lag as much as possible.
Basically I'm copying the pixels of said FlxCamera onto an FlxSprite, and then I'm rendering that FlxSprite's pixels to a normal Sprite (openfl.display.Sprite), which then gets put onto the window. The lag doesn't seem to be coming from putting the camera onto an FlxSprite, it seems to be coming from putting the FlxSprite onto the Sprite (this is all in the update function btw). Is there a better way to put the FlxSprite onto the Sprite without having to copy the pixels every single frame? Or possibly a better way of copying the pixels that lags less?
This is the current code for it (just the FlxSprite to Sprite part):
notesSprite.graphics.clear();
notesSprite.graphics.beginBitmapFill(cameraSprite.pixels, new Matrix());
notesSprite.graphics.drawRect(0, 0, cameraSprite.pixels.width, cameraSprite.pixels.height);
notesSprite.graphics.endFill();
I've tried removing endFill(), nothing changed. I've tried removing drawRect() from update and only calling it once but that made the Sprite empty. I've scrolled through all the functions and variables to see if there was another way, but it didn't seem like it.
running clear() does seem to reduce the lag a lot, but considering I have a really good pc and it's still bringing me down to 60 fps, I wanna make sure the game is playable on other people's pcs that may or may not be as good. I've yet to test this on a worse pc (I'm gonna send a build to my friend soon so he can test it), but seeing as I'm working with a rhythm game I wanna make sure that the fps stays at 60 or higher constantly.

Why does my object "sink into the ground"?

I have a rather simple react-three-fiber setup that includes cannon.js-powered physics. In the scene there is a cup -- which is modelled as a cylinder whose top radius is bigger than the bottom one -- that is placed on a surface.
When I run the code, during the loading screen everything looks fine. But when physics kick in, the cup suddenly "sinks" into the ground. Why is that? I can't make sense of that...
One theory of mine was that the "physics shape" of the cylinder is not identical with the "optical shape" that gets rendered, but even then the movement I observe still doesn't make sense with any reasonable bounding box I can imagine...
Working example: https://codesandbox.io/s/amazing-proskuriakova-4slpq
Physics are finicky and really hard to debug because you're often trying to intuit the effects of an invisible system by its effects on whatever hybrid view you have.
I notice if i bring the mass downn to a more reasonable value, like 5, the object appears to roll around like a sphere or some other shape.. so I think your theory is sound. I don't know off the top of my head what the solution is, but I do know that the only physics engine I "trust" in the js space, except for very simple simulations, is Ammo.js. It's hard to use, but is an emscripten port of a truly amazing AAA quality library. https://threejs.org/examples/?q=phys#physics_ammo_break
I would start by getting a cube and a sphere working.. once you have verified that those work as expected.. ideally using real-ish world scale units, like a 1x1x1 cube, with a mass of 1. Use a texture on the sphere so you know that its rolling like you expect. Once you have verified the simpler primitives work, move onto the more complex geometries.
Best way forward would be to make an issue on the use-cannon GH. That lib and cannon-es are under active maintenance now. Meanwhile, i believe convexpolyhydron can also do it flawlessly, see: https://codesandbox.io/s/r3f-convex-polyhedron-cnm0s

Skeletal animations in C# SFML 2D

I'm completely green when it comes to skeletal animations in 2D. I create a platform game and I got graphics for it - body parts from which to stick the character. My problem is that I have absolutely no idea how to go about it. The question is: How do you implement animations in the game?
I could do it frame by frame from previously glued body parts, but I need the character to look at the mouse cursor, so it falls off. I am asking for some ideas.
About your problem, if you want all parts of your character look at the mouse, you should rotate your character, if just a part (like character's head) you need to rotate the head.
I could give you some methods to implement animation that I known
Draw animation frame by frame: simple, easy to approach and handle but hard to scale up.
Separate character into many parts and each part has a unique animation: flexible, good for scale up but hard to handle due to you must ensure all parts are stick together in a right way (from scratch without tools or engine). I think this video may help you to know more the way their create skeletal animation in Unity (same as Spine).
Hope it help.

Unity 3D Several objects not showing on the screen everytime the level is loaded

I have a simple 2D game and I have a strange problem whenever a level is loaded several of the objects that include platforms and enemies won't display on screen and neither do the 2D background but all the objects are there, I can see it in the hierarchy and they are functioning as they should like killing the player and such. They just don't show up on the screen. I was finally able to show them while pausing the player during gameplay and set the z position of the camera to -11 and above but every time the level reloads like after the death of player, the same problem happens.
I even tested it on the mobile device but the same problem occurs furthermore I can't even interact with any of the UI buttons on the level, even though I check that all the code for them is appropriate.
Please help.
EDIT:
Okay after reading, your replies, I thought may be this will help. O always get these errors every time I load up this project in unity but they disappear once the game is running.
As you can see the platforms and enemies does appear on the camera frustum but when I start the game they disappear.
Okay, I finally found the problem. After lot of head scratching and testing I found that the objects that weren't appearing on screen has their z-position set to -10 which is the same of that of camera's z-position.
The problem was I was using this code to set the position of objects in the Awake method:
transform.position = camera.main.ViewportToWorldPoint(new Vector3(x, y, 0));
What's actually happening is all the x, y, and z co-ordinates were setting related to the camera's position. So setting the z-position to 10 fixed it for me.
Thanks everyone for helping me.
It's probably because near clipping of your cam is to high; Set it to 0.1 and try it again.

Hierarchical animations in DirectX and handling seperate animations on the same mesh?

I have a hierarchical animated model in DirectX which loads and animates based on the following DirectX sample: http://msdn.microsoft.com/en-us/library/ee418677%28VS.85%29.aspx
As good as the sample is it does not really go into some of the details of animation that I'd like. For example, if I have a mesh which has a running animation and a throwing animation as seperate animation sets how can I get the throwing animation to occur for bones above the hip and the walking animation to occur for bones underneath the hip?
Also if I wanted to for example have the person lean left or right would I simply have to find the bone for the hip and multiplay a rotation matrix by its matrix? In this case I think the matrix is m_amxBoneOffsets?
Composing multiple animations to a single one is usually the job of an animation system, something that is way out of scope of the D3D sample.
Let's look at your 2 examples:
running and throwing
Well, in this case you could apply the animation for the lower part of the body from the running animation and the animation for the upper part of the body from the throwing animation. And you'd get a very crappy result.
The how is just a matter of knowing which bones are where in the bone palette (something that depends on how they are stored, and in which order, but nothing inherently hard. The definite reference should be the documentation of the tool generating the animation data)
In practice, you're better off with a blending of the 2 animation. This is, in general, is hard, and software packages exist out there that do this for you. Gamebryo, e.g.
Or, an animation of a running guy who throws is different enough from a standing guy who throws that you might be better off having 2 animations.
Leaning
If you apply a rotation matrix to the root bone, you'll simply rotate your whole character.
Now if you rotate the next bone in the hierarchy (from the spine), you'll get all the bones that depend on it to rotate likewise. It will probably do what you want, but there's a sure way to find out. Try it!
Well the thing is the running animation SHOULD affect the throwing animation slightly. What you need to look into is animation blending.
I'm sure Valve wrote a good paper on how they implemented it in Counter-strike many years ago. Its not on the valve site though so I'm not sure where I got this memory from ...

Resources