Rotate wheel collider object - unity3d

I wanted to rotate a wheel collider object in unity.
I duplicated my back and front wheels objects to keep the position data.
It appeared perpendicular to the wheels. I cannot rotate it using the rotation tool or via the inspector.
As mentioned in this post: it could be solved using an empty game object for the rotation.
I tried to append it onto an Empty Game Object and rotate it. It did not work.
Thanks in advance

I had the same problem. The solution is simpler than the other answer suggests:
WheelCollider objects are dependent on the orientation of a rigid body they are attached to. Assuming that your bike has a rigid body, the solution is to make sure that the X-axis orientation of the bike matches the 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 bike's model(the visuals that display bike's frame) 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, that would also rotate my 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.

1-) Create a capsule game object,
2-) Make it like whell.
3-) Delete capsule collider and add mesh collider, then select convex.,
Now you have a collider like whell.
4-) Put your whell game object under this, and fix sizes.
5-) Delete mesh filter and mesh renderer in capsule object.
6-) Use transform.rotate(vector3.right) or left on created base object.

Related

How to add a text to be like attached to a gameobject relative to the gameobject rotation?

I have this model and the model is rotated on the x by -90 so the model is a bit pointing to the ground on the left side :
and now i want to write some text on it's side on the surface.
the easiest way is just to add a simple empty gameobject as child of the ship and to add to the child a Text Mesh component :
but now i have to play a lot with the text object rotation and position to find the exact settings that it will be like painted/attached/curved on the ship surface and to be in the same rotation pointing a bit down to the ground to the left like the ship.
and even if playing with it so much time it will never be 100% accurate.
is there any way to attach/pint/curved the text with the same rotation of the ship easier ?

Unity Character Controller

Have Mesh Colliders on everything except the Solider being a child of the Game Object renamed Player.
The Player has a Character Contoller surrounding the child or blue-colored soldier. In Game Play, he falls halfway through the road and gets stuck in Unity. Is there a fix for this????
I noticed the Unity forum had not answered a similar question about it since 2019.
Colliders
Make sure that the actual model / mesh of your character has a mesh collider applied to it and that the convex box is checked. Next make sure that your ground / whatever your character lands on has a collider attached to it whether this collider is of type mesh, box or really any collider it shouldn't matter but I'd recommend trying a cube with a box collider first. Also make sure that all of your mesh colliders actually have a mesh applied to them.
For your character controller double check that the size of it matches your characters model in both width and height. Apply the actual Character Controller to the Parent game object in your case named Player and apply the mesh collider to your actual character.
Some Images of how it should look when correctly set up
How the parent "Player" should be set up simply
How the actual character should be set up simply
How your ground should be set up simply

How would I keep the rotation of the look of the object but make the rotation 0 Unity

How would I be able to have Wheel look the same but make the rotation 0.
As already commented you can rotate the mesh in 3D modeling software.
A faster way would be to parent the GameObject that represents the wheel under another GameObject, which will be acting as a pivot then. Just position it at the exact position of the wheel GameObject, but with a the desired rotation.

Unity - handle OnCollision on child's Rigidbody

I have a GameObject, constructed from bunch of pills, where each pill is basically constructed from two spheres and a cylinder.
So the GameObject hierarchy looks something like this:
Player (Empty GameObject)
Pill (Empty Game Object)
Sphere (3D sphere)
Cylinder (3D cylinder)
Sphere (3D sphere)
Hopefully the picture will give you guys the visual illustration of what the GameObject looks like:
Now, my goal is to have the entire GameObject - Player as a Rigidbody, while I would like to detect collision on Pill level. Hence I added Rigidbody to Player and Capsule collider to each Pill. However such configuration does not work - the Pill does not receive OnCollisionEnter event. I found suggestion solution, however it does not work for me either - if I set Capsule collider property Is Trigger, then Player does not interact with other Rigid bodies. The only solution I found so far is to add Rigidbody to each Pill, but I am concerned about performance is such scenario.
To sum up - my question is - can I have the above configuration - parent rigid body, child collider work and accept OnCollision events? Of course if I can have parent rigid body and a child with Is Trigger set will also work in case the Player keeps rigid body physics behavior.
I don't know why you want to detect collision on Pill Level but retaining the same configuration one thing you can access is the Collision ContactPoint.

animating object along a path in unity 3d

I need to animate an object along a path. I am doing so by creating an animation like:.
This works great but since my terrain is not flat it will be nice if I don't have to deal with the y component. In other words I want to move an object along the x-axis and z-axis and if there is a small slope increase then increase the object y position. same thing if there is a downward slope. Or maybe I have to create a script where it checks to see if the object is colliding with the terrain. if not then decrease its y position. I don't know if this will work meanwhile animating an object though.
I think the easiest way I can think of to solve this is for you to make the object a rigid body and use collision (probably a mesh or capsule collider if its a player character) to get it to sit on the floor.