- Home /
Wrong collision positions when rotated/transformed object
I am creating a mesh by code through adding collision positions between the object with the script attached and another object to a list. The created mesh's transform is parented to that other object in Start() since it's supposed to move together with it. This works as intended as long as the parent object hasn't been moved yet. The problem now is when the object gets moved or rotated (which is wanted). After translating or rotating the parent object - and the child object with it - the existing points are transformed and rotated as intended but the newly added points don't appear where the collision happened.
I first noticed that the new points seemed to be rotated twice as much as they should have been when rotated around the Y-Axis which is why I tried the following
positions.Add(Quaternion.Inverse(newMesh.transform.rotation) * P.point);
instead of just adding "P.point" (with P being the ContactPoint). This worked as intended but after that I noticed that it didn't fix the problem when rotated around the X- or Z-Axis. Also when the object gets transformed freely the same problems occur. This also happens when just adding P.point
If anyone has any thoughts about why this happens and/or how it can be fixed, I'd appreciate it. Thanks. Also if more information is needed, just let me know.