سؤال

I have an imported model in .fbx format, with pre-baked animations. I want to apply physics to the model, however playing the animations seem to interfere with the physics

When the animations play the model won't 'fall'/collide but if I untick the 'Animation' in the inspector my model reacts correctly to the physics rigid body/mesh collider applied to the gameobject, but the minute I switch back on the animation the model moves back to it's original start position (but does play the animations correctly)

What am I doing wrong?

EDIT: This is the 'Animation' tick box I was talking about:

Screenshot of inspector in unity showing Animation component

هل كانت مفيدة؟

المحلول 2

I was able to solve it by following this advice and making an empty game object to be used as a container, add the rigid body/mesh collider/scripts to the container game object, then add my model as a child of that game object. This way the transformations applied in script apply to the container, and the animations no longer affect the movement of the model!

نصائح أخرى

I'm a little unsure about this "Animation" checkbox you are referring to, but I have a couple hunches you can explore.

Unity's physics and collisions comes in a lot of flavors, and not all of them mix very well. Rigidbody is good for anything that will have physics associated with it, but it comes with a TON of strings attached. For example, Rigidbody's only collide with other Rigidbodys (see bottom). It sounds like you want to move your physics-thing around as a player or enemy or something. RigidBodys are mixed when it comes to this.

The setting you need to play with is ".isKinematic" for the rigidbody component. Turning this on turns off the physics simulation for rigidbodys, and the character controller or whatever will fall back as the default. Check out this script to toggle physics to so your character can push stuff around: http://answers.unity3d.com/questions/17566/how-can-i-make-my-player-a-charactercontroller-pus.html

The other thing to keep in mind is that your model should not transform around the world in animation. Any transformations need to be handled by your game behaviors.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top