Changing location of wheels on a vehicle
Changing location of wheels on a vehicle
Is it possible to change the location of the wheels of the wheels from the vehicleInput class?
Re: Changing location of wheels on a vehicle
Yup. The WheelSuspension constructor takes the location of the wheel in vehicle body local space.
It can also be adjusted post-construction by changing the Wheel.Suspension.LocalAttachmentPoint.
It can also be adjusted post-construction by changing the Wheel.Suspension.LocalAttachmentPoint.
Re: Changing location of wheels on a vehicle
Thanks! I can't believe I didn't see that before. I have another question about the vehicle. I tried to make a MobileMesh as the body of the car but in most cases the car either doesn't move, or the wheels start to bounce around and glitch into the surface they are on. Can I not use a MobileMesh for the body?
Re: Changing location of wheels on a vehicle
A MobileMesh, or any entity, should work fine for a vehicle body.
The mesh used to create the MobileMesh may have inconsistent winding or the MobileMesh may be given the wrong winding. If it's using Counterclockwise sidedness, try Clockwise sidedness. If both fail, try using DoubleSided. If DoubleSided works but both one-sided options fail, the mesh likely has inconsistent winding.
If the car cannot move at all, make sure the entity was created with mass. Entities created without mass are kinematic.
Here's a part of the VehicleInput constructor modified to use a MobileMesh:
By the way, it's typically better to approximate the shape with simpler objects. For example, if the shape can be represented by a few boxes in a CompoundBody, that will be a lot faster than a MobileMesh of 1000 triangles. A CompoundShape of a few ConvexHullShapes is a good midpoint between source fidelity and performance. However, the vertex data used to create the ConvexHullShapes would ideally be simplified compared to the graphical version to avoid unnecessary cost.
The mesh used to create the MobileMesh may have inconsistent winding or the MobileMesh may be given the wrong winding. If it's using Counterclockwise sidedness, try Clockwise sidedness. If both fail, try using DoubleSided. If DoubleSided works but both one-sided options fail, the mesh likely has inconsistent winding.
If the car cannot move at all, make sure the entity was created with mass. Entities created without mass are kinematic.
Here's a part of the VehicleInput constructor modified to use a MobileMesh:
Code: Select all
Vector3[] vertices;
int[] indices;
TriangleMesh.GetVerticesAndIndicesFromModel(wheelModel, out vertices, out indices);
var body = new MobileMesh(vertices, indices, new AffineTransform(Matrix3X3.CreateScale(5, 2, 9), new Vector3(0, 0, 0)), MobileMeshSolidity.Counterclockwise, 61);
Re: Changing location of wheels on a vehicle
By changing the MobileMeshSolidty to Counterclockwise I got the bouncing and the glitching to stop, but the car still won't move. The wheels turn and rotate when I attempt to move but the car goes nowhere. When the car is inactive I can push the car around a little bit so I know it can be moved.
Here is the code I'm using to get the initialize the mobile mesh.
Model bmw = Content.Load<Model>("bmwCollision");
TriangleMesh.GetVerticesAndIndicesFromModel(bmw, out vertices, out indices);
MobileMesh bwmBody = new MobileMesh(vertices, indices, new AffineTransform(new Vector3(0, 0, 0)), MobileMeshSolidity.Counterclockwise, 61);
Here is the code I'm using to get the initialize the mobile mesh.
Model bmw = Content.Load<Model>("bmwCollision");
TriangleMesh.GetVerticesAndIndicesFromModel(bmw, out vertices, out indices);
MobileMesh bwmBody = new MobileMesh(vertices, indices, new AffineTransform(new Vector3(0, 0, 0)), MobileMeshSolidity.Counterclockwise, 61);
Re: Changing location of wheels on a vehicle
Do the wheels reach the ground?
Re: Changing location of wheels on a vehicle
That was it. It took some messing with the local position too, but it seems to be function now thank you!