- Home /
rigidbody + mesh collider + addRelativeTorque
Hi,
I'm using a helicopter controller script that works fine when i have a box collider on my model. When i switched to a mesh collider, everything started to go wrong.
I was able to fix the forward/backward movement by setting the CenterOfMass manually to (0,0,0), But i can't seem to be able to fix the rotation controls. Its spinning along all the axes instead of just the Y axis, and this also causes it to change position.
The way i'm rotating my model is this:
torqueValue -= (Vector3.up x max_tail_Rotor_Force x tail_Rotor_Velocity);
rb.AddRelativeTorque(torqueValue);
And ofcourse when i switch back to the box collider everything works fine.
Is there a way to fix this or should i also keep my box collider, and make all of the other colliders in my scene ignore it using Physics.IgnoreCollision?
Thanks
I would recommend using box collider(s) over mesh collider because mesh colliders are quite inefficient (even though this is just one game object) and as seen in the picture it doesn't really do a great job covering the helicopter. From my experience mesh colliders are just so much more difficult to work with.
I need a mesh collider in order to mark exact hits (when the object is being fired on). so i will have a mesh collider anyway. But efficiency aside, it's just a question of do i still need the box collider on top of that so that AddRelativeTorque will work properly or is there a way to fix that.
WOW! That mesh collider is pretty messed up! I recommend you creating your own mesh collider inside any modelling program, though it will much much more accurate than what i see here. For your question we neef to see the script.
thats because its around the whole model and not just the hull. once i seperate that into an object of it's own i'll put the mesh collider on it and it will be fine. i'm just playing around now.
as for the script, even if i have just a line saying addRelativeTorque and i add a value for the Y axis only, it will start spining diagonally because of the shape of the mesh.
Answer by reihe0 · Apr 11, 2015 at 03:03 PM
Why don't you use a box collider for the movement and the mesh collider on another object to check for collisions?
I can use both on my object, i just prefer to know if there's a way to fix it so i can use only mesh collider.
I had the same problem with addRelativeTorque for going forward and backwards and i fixed that by zeroing the CenterOf$$anonymous$$ass, but this didn't solve rotating the helicopter. and i guess I have to find the currect spot to for the center of mass to fit all directions of torque, I just don't know how.
Your answer
Follow this Question
Related Questions
LookAt but using physics AddRelativeTorque 1 Answer
Vector3 and AddRelativeTorque 1 Answer
Sphere movement very erratic and uncontrollable. 1 Answer
Keep a rolling balls momentum 1 Answer
Physics-based Homing Missile 2 Answers