Okay, I limit my target angle without limit angle.
Limiting the target is indeed probably the better option compared to using a limit to constrain the motor, but I'll go ahead and explain the usage of the limit for completeness. The two most directly useful properties are the RevoluteLimit.MinimumAngle and RevoluteLimit.MaximumAngle. These properties are relative to some angle which is defined as 0 (which I'll get to in a moment), but an important thing to note is that the minimum and maximum angles can encompass any part of the rotation. Even if you don't configure the 0 angle, you could set the angles to compensate.
For example, setting limits like this:
Code: Select all
axisJoint.Limit.MinimumAngle = MathHelper.PiOver4;
axisJoint.Limit.MaximumAngle = MathHelper.PiOver2;
limits the rotation to an angular area of pi / 2 - pi / 4.
On the other hand, reversing the endpoints:
Code: Select all
axisJoint.Limit.MinimumAngle = MathHelper.PiOver2;
axisJoint.Limit.MaximumAngle = MathHelper.PiOver4;
limits the rotation to an angular area of 2pi - pi / 4. It starts at pi / 2 and wraps all the way around back to pi / 4.
To adjust the zero angle direction, set the limit's Basis accordingly. The 'basis' is the constraint's frame of reference. It's attached to the first entity of the connection, so as entity A moves around, the basis will follow it. As described in its intellisense comment, the primary axis of the basis is the rotation axis. The secondary axis- which must be perpendicular to the rotation axis- is the direction of zero angle. The combination of the rotation axis and zero angle axis is used to compute the 'winding' of the angle consistently; that is, which rotation is a 'positive' angle and which rotation is a 'negative' angle.
For example, if (0,1,0) was the rotation axis and you wanted (1,0,0) to be the zero angle direction (both in world space), you could set it like so:
Code: Select all
axisJoint.Limit.Basis.SetWorldAxes(Vector3.Up, Vector3.Right);
1) When the tank go forward, the wheel rotate great, but when a collision appear the wheel don't rotate, so the graphics wheel don't to. How I can solve it ?
The wheels do not actually exist, so they aren't ever really rotating. The apparent rotation of wheels is a convenience computation performed based on the relative velocity between the ground and the cast impact and the radius of the wheel.
Since the effect is purely graphical, you can choose whatever method you want to make the wheels spin. For example, you could arbitrarily make the wheel graphics rotate at a fixed rate whenever the tank is told to move.
2) When the tank go forward an obstacle, the turret go inside the obstacle, I think is that the mass of the tank is too important but can I solve it too ?
This is related to the mass ratio issue. When the turret hits the obstacle, the heavy tank body depends upon the lighter turret. If the turret's connection has been made extremely rigid, the collision constraint might be the weakest, resulting in penetration. You can force collisions to be infinitely rigid by setting the CollisionResponseSettings.Softness to 0. Setting softness to zero may not end up producing a pleasing result. Depending on the severity of the mass ratio isssues, something could end up freaking out a little bit.
Note that, when using nonzero softness, the softness scales with the effective mass of the collision. So, increasing the mass of the turret will make the impact more rigid without touching the CollisionResponseSettings.Softness field.
3) The radius of wheels is too low, so the collision doesn't take all my graphic model and if I take a raidus more important, the tank doesn't rotate great, so how I can solve it ?
When using CylinderCastWheelShapes, increasing wheel radius will effectively increase the height of the vehicle. This may be responsible for the change in behavior. Shrinking the suspension length appropriately may fix this issue, though a shorter suspension will also subtly change behavior.