I have moddeled and rigged an human in blender and I am able to play that animation in unity.
Now I am trying to add some objects to the human. For example an hat. But I cannot figure out, how it is made that the hat moves withe the animation.
I know, that the head has got the animation data. The hat does those data not have, hence the hat does not move.
How do I do this? Another scenario would be grapping sth. with the hand and that object should move together with the hand movement.
I would like to add those objects via script later on.
Thank you very much :)
In your character's rig in the unity scene,
Find the Bone that you want your target GameObject to follow, and add the target GameObject as a child of the bone GameObject in the Scene heirarchy, and position it with whatever position and rotation offset you need (In this case, on the head bone, maybe a little tipped)
In this case, you would find the Head bone of your rig, and add the Hat as a child gameobject of the head bone. Any animation you play, which modifies the bone positions should also move your target GameObject.
Related
I can't move uploaded models in the Unity with NavMeshAgent. They just walk while standing still. And whenever I start the game it gets it's "y" position as something different than it should be. This might be the problem but there's nothing that changes the position.
To use NavMeshAgent you need to add Rigidbody component to your uploaded model and also bake your NavMesh like terrain, obstacles and so on.
So I've animated my spaceship. With it's previous rigid form I've got a particle system coming out of it's wings. Now that it's animated, I still want those particles to follow all of it's wings movements, but the particles don't move along with the animations, even being parented with the gameobject's wings, showcase video, 19seconds: https://youtu.be/XJNjT4s4X6I
How can I make those particles move along with it's wings movements? Thanks
I would try to parent them with the bone of the armature, I don't remember if it worked for me though, but what I did is to add an empty in the modeling program to follow the animation and export it, so I can parent it to the things I needed, for you It would be the Particle System.
I can't seem to wrap my head around the following, I have a simple spaceship with 2 turrets:
My 'Player' the white ship has a rigidbody. The turrets have not.
I'm moving and rotating my player via the rigidBody, however I would like to also rotate the turrets via the physics system.
I thought about adding a rigidBody2D to the turrets, however that was not recommended from my understanding reading posts online. This is because rigidbodies in children would affect the parent in unforseen ways.
So dropping that idea, How can I move my turret and having it be affected by physics?
Some sidenotes:
I want the turrets to be influenced by physics. Lets say i try to rotate my turret, but it hits a wall, I want it to resist. Lets say some debris hit my turret's barrel, I want it to move in the opposite direction.
Although i could move the turret outside of its parent's container (the ship) I do ofcourse want it to 'stay on the ship in game'. The turret is part of the ship, its mounted to the hull or fuselage if you will. So it should move with the ship and keep its position.
As mentioned by derHugo joints where up for the task, although i had to restructure a bit, here is the outcome:
I added an empty transform to hold the ship and its sub-components, so turrets are no longer part of the ship parent, so that i can add a rigidBody to these child objects now.
Then I added a hingejoint and rigidbody to the player ét voila, it now works:
I still need to take a good look at how joints work exactly but this seems to work.
I am trying to hit a ball using a golf club. My golf club has three components (three game objects: handle, shaft and head as shown in the first attached image). Head gameobject's inspector can be seen in the another attached image.
To hit the golf ball, we need a collider. So I put a Capsule Collider at head game object. But I don't see any collider at head gameobject.
The head is shown in the last image.
Why I can't put Capsule Collider at the object?
EDIT:
Thanks for the reply.
I increased the radius but still the same.
I placed a Quad in the scene and put Mesh collider onto it (called AW52Collider). Please see in the
first image. We can see the collider clearly.
But I did the same thing to Club head, as it is also a game object I should be able to put a Mesh collider. But I don't see anything. Why?
Please see in the second image.
One more thing I don't understand is when I put AW52Collider inside Club Head object, I don't see AW52Collider also. Why? Please see in the third image.
Increase the size of your collider, those values do not look like you should see the gizmos at all. Best would be to reset the collider to its default values and then play with them until you are happy.
It is best practice to create a child object with colliders on it. The reason is the placement of the collider. The collider is always centered around the pivot point of a GameObject. But you probably want to move your collider freely or disable a group of colliders manually for testing (or optimization) purposes. Also consider that an object with multiple small colliders as child objects is considered one big collider (rigidbody wise). Source (Compound Colliders)
Just enable Gizmos button and you'll find your capsule collider.
See this picture to know exactly where to find it:
(It's in the toolbar below the Scene tab)
I want to add a wheel collider in my car wheel but it comes with 90-degree rotation.
This is the image:
How can I adjust the collider to the car wheel?
For further reference, i am writing down my comment as answer.
Simplest solution that i can think of is; add an empty gameObject. Attach wheel collider to that empty gameObject. And make the empty gameObject child to your car's wheel. With this you can rotate the empty gameObject so that your collider will be rotate. #Programmer also shared a link about WheelCollider Tutorial. Which can be found here
One of the best thing you could do is that, before importing the game object, make sure that the game object is Y Forward. You can change that in blender while exporting.
I had the same problem. However, simply rotating an empty parent object doesn't work in the modern version of Unity (2019.4). You have to rotate an object that has the rigidbody that the WheelColliders are attached to.
Assuming that your car has a rigidbody, the solution is to make sure that the X-axis orientation of the car's rigidbody matches the desired X-axis orientation of the wheel colliders.
Based on this post:
https://forum.unity.com/threads/unity-5-wheelcollider-wrong-rotation.349596/#post-2264801
WheelColliders always point in the "forward" and "down" direction as the rigidbody they're attached to. The steerAngle value is relative to the rigidbody's forward direction.
Please bear in mind, however, that your car's model(the visuals that display the car body) might have a different orientation from the object that contains the rigidbody that wheel colliders are attached to.
In my case Hierarchy looked like so:
MainScene
CarRoot
CarModel
WheelColliders
Wheel_FR
Wheel_FL
Wheel_RR
Wheel_RL
The CarRoot had a rigid body on it. When I rotated it, it would rotate the wheel colliders with it. That would also rotate the car model. Which was not good. So I had to:
Unparent the CarModel and WheelColliders(made them children of MainScene)
Rotate the CarRoot by 90 degrees on the Y-axis(to align its X-axis with that of the WheelColliders)
Make CarModel and WheelColliders children of CarRoot again.
That did it for me.
P.S. Sorry if this is a bit of a necro-bump. But this still has no answer.
I had a ton of trouble over this because none of the export settings or rotations in Blender fixed the problem for me. I eventually found a solution though. Create an empty gameObject, and attach the rigidbody, mesh filter, and mesh collider to it. Then parent the model to the empty gameObject, and then try adding wheel colliders. Wheels are relative to the rigidbody's transform.up and transform.forward, so putting the rigidbody on a default thing fixes all the issues.