Closed NovemberDev closed 4 years ago
Bullet doesn't support scaling the transformation matrix.
Try this:
groundShape.LocalScaling = new Vector3(50f, 0.1f, 50f);
You'll need different shapes for different sized boxes.
Thank you for the quick response!
I just tried that and there still is no collision with the scaled ground: https://streamable.com/1enu0
I solved it!
If someone happens to have the same issue, here is what I did:
// don't apply rotation or scale
DefaultMotionState myMotionState = new DefaultMotionState(Matrix4.CreateTranslation(entity.Position));
// when you sync your transforms, apply scale:
Entity.TransformationMatrix = Matrix4.CreateScale(Entity.Scale) * World.CollisionObjectArray[i].WorldTransform;
Thank you for helping me :)
There are a few ways to work with scales. 1) Pass the required dimensions to the BoxShape constructor and render a graphical box shape of the same size. Keep LocalScaling = 1.
2) Pass the required dimensions to the BoxShape constructor and render a unit box (size 1) scaled by the dimensions given to the BoxShape. Keep LocalScaling = 1. (I think this is what you did.)
3) Create a unit box "new BoxShape(1)" and scale it using LocalScaling. The graphics engine should render a unit box scaled by the dimensions given to the BoxShape and also by LocalScaling.
LocalScaling is more useful for complex shapes, e.g. if you have a triangle mesh shape that is difficult to scale otherwise.
Hello,
Whenever I use this method:
and replace Matrix4.CreateScale with Matrix4.Identity, my collisions work, but when I leave it that way, they won't work at all. I tested this with a BoxShape (50, 0.1, 50) and falling Cubes (BoxShapes).
When I put these lines into the demo project:
I get a very weird effect that I don't quite understand. So what is the deal with scaling and how would I do it in this case?