I have a roll animation for my character and added the Capsule Collider.Center and Capsule Collider.Height properties to the animation to change the collider's size during the animation.
It won't let me adjust the properties without changing the permanent properties of the collider. I can hit record or select a key and adjust the properties I want, but then all keys for those properties and the properties on the collider on the GameObject are changed to those new values.
To make sure that a collider can be animated, I created a new capsule in the scene, created a new controller for it, then added those same properties to a new animation. That works perfectly, the properties I'm trying to animate work just fine. Why is it not working on my other animation?
Also, I'm using Unity version 2019.4.18f1.
Edit: I can use events to change the collider's size through script, but it would be much smoother if I could animate it with the animator.
I sort of figured out the problem, it's somehow related to how I have my player character made in the Hierarchy. The object with the issue has one level higher of nested objects, that's the one called player. The one that works perfectly and allows me to animate the properties on the Capsule Collider, is the RPG-Character. Every component on the parent objects are identical, RPG-Character has an exact copy of every component on Player, along with their values. I don't get it, but this has fixed my issue.
Related
I'm having a peculiar issue with my character controller collider. in the image provided the controller SHOULD fall down the side of this cube object, yet it "floats" or "hangs" on the corner which isn't a detrimental problem, but is something I'd like to fix now rather than later, any ideas?
image of the controller statically floating on the edge of a cube object
I initially thought this issue may of been caused by incorrect properties within the controller, however after experimenting with the values the issue has not be resolved. I even tried ray casting to determine whether the controller is actively colliding with an object, but to no avail.
The problem is
it seems that the problem isn't directly on the collider but rather on the material you're using (which in this case, none)
Solution
from your project's asset, right-click and select create -> Physic material. From that physic Material, set the both Dynamic and Static friction to zero, then just draw that physic material to the game object. you can also adjust the friction depends on your needs
Character Controller has a skin width. Its an extra layer of collider which may cause this. Also check if the collider is within the capsule bounds. You can check out this article on Unity Character Controller for more details.
In my Unity 3D project I've added an animated body as a child to the Player object. The player moves as is should, with the right animations displaying for each key. The problem however is that the transform of the child changes when I enter game mode, meaning the character is walking above the ground. In scene mode it's relative to it's parent, it's grounded, but when I switch to game mode the character suddenly changes it's y-axis transform. I also checked the inspector for this object, it's y-axis changes.
I tried disabling the movement script, to check if this could have anything to do with it, but nothing changes. The transform still changes. I'm new to this problem, and every thread I've found on the topic hasn't helped much. Does anyone know what might cause this?
The hierarchy. mixamorig:Hips is the one changing it's transform. The animations and animation skin I'm using is from Mixamo.
So I worked on humanoid body that stays with his hands up all the time (I added the health, moving script, gun pickup/drop etc). How I want to implement the slight hand motion when standing. I exported the animation from blender to unity and when I added the animation controller to the player it does not work, but if I drag the new character from the new animation package it works. Is there a way I can apply the animation from one to another (the one I worked one has different sizes than the other one but bones names are the same) without moving all the scripts and features from the old one to the new one with the animation?
created a prefab for door and added the prefab doors to the scene. This prefab door has an animator. The problem is when I try to change the animator x,y,z position on the second door in the scene it changes the first door.
I tried duplicating the doors and changing the position x y z but it changed the animator for the first door.
I just have a script that play the animator.
The expected result should be that I can drag and drop doors as needed without creating individual animators for each door. It looks like i need to create animators per door there is and also this probably will require me to create new scripts per each door. It seems awkward since I should be able to add doors and just chaning the position x y z in the animator.
The problem is that their Animator component uses the same AnimatorController asset which uses certain AnimationClip asset references for it's states.
I don't know if there is an easier way for achieve but I would do the following:
For what you want you would have to copy the AnimatorController asset (CTRL+D) as well as the AnimationClip asset you want to change.
Then in the cloned AnimatorController click on the according State you want to change and in the Inspector reference the according cloned AnimationClip.
Now you have a copy of the AnimatorController using a different AnimationClip but with the same states, traditions etc. so you can edit both animations and controllers individually.
finally in the Animator component reference the according AnimatorController for each prefab.
The remaining problem maybe is now that for the future if you change the States, transitions and especially parameters you have to do it in both AnimatorController assets individually.
That is perhaps not because of an animator, but a specific behavior of animation in Unity. Animation animates transform property according to parent, as far as I understand. So the first parent of your prefab is captured, and its transform property is used for animation. But I'm not exactly sure about this explanation - the actual behavior is covered under the Unity's source code. A common solution for this that I found is to create a parent or container inside your object's prefab. I don't know why it works, but it works. Perhaps because the parent of your animated object is now always the same.
Parent can be just an empty game object. So you make your door prefab, place another empty game object into this prefab, make your door a child of this container, set 0 for all coordinates of your door according to container and for the container itself. Now you can add an animator component to your object, which you want to animate (not the container), and animate it inside the prefab scene. After that you can place the copies of this prefab (container + your animated object inside) wherever you want inside your game scene - all animations of copies will proceed independently.
I created a bunch of non-AI animations for enemies that do basic back.forth or up/down motions. Everything was working perfect until I started working on the Boss of the level. The boss has his own tag "Boss" and enemies have their own tag as well. Anyway, the problem is when I click start, every enemy leaves the game board. I can see them animated above the game board still doing their routines.
Any clue as to why this happened and how to fix it? I'd really, really hate to have to scrap all the enemies and start from scratch...
I used the Animation tool inside unity.
Extra Note: I created an EMPTY and moved all of my enemies into that Empty object to clean the hierarchy panel up. The animations were fine before this.
************** Currently Resolved **************
Whew! Okay, so apparently Unity doesn't like it when you move your animated stuff into an empty AFTER being animated. I FIXED them by simply removing them from the EMPTY that I had placed them in. However, I'd still like to know why this is. So any useful resources, links, manuals, personal insight/observations or anywhere I can read up on this would be appreciated!
Here is an explanation what happened:
The moment you dragged them all into the empty GameObject I guess this object probably wasn't placed on 0,0,0 in the Scene.
So Unity automatically changed all the local position values of your enemy items to fit the current position offset to the empty object.
Result: In the editmode they don't change their actual global position in the scene but their local position. This is supposed to happen if you just want to organize stuff.
However, now when you start the game and the animations are played, the animators change all the local positions to whatever is stored in your animations.
Result: all objects jump back to their original localPosition which had an offset to the empty GameObject.
To solve this make sure the empty GameObject is at position 0,0,0 and optimally has rotation 0,0,0 and scale 1,1,1 before you drag anything into it.
Easiest way to achieve that is by clicking reset in the empty objects Transform component before starting to drag stuff into it.