Hi,
I have an object, let’s call it “block” and a child object called “block collider”. The block object has a 3D mesh, but exists in a 2D physics world, so the 2D “block collider” is handling all of the physics stuff.
The idea is that the block rotates, because it looks pretty, while the block collider stays static and facing the screen, so I can use it for touch events and 2D collisions.
However, the block collider child object is rotating with it’s parent. Something I don’t want to happen - as it messes up the shape in the 2D world. It does this, even though the transform.rotation values can be static (0,0,0) or moving (either aligned to the parent or not).
So far I’ve tried the following code in the block collider’s controlling script:
void Update ()
{
transform.localRotation = Quaternion.identity;
}
I’ve also tried: transform.LookAt(Vector3.zero);
and: transform.Rotation = Quaternion.identity;
and: transform.eulerAngles = new Vector3(0,0,0);
and a mixture of trying to subtract Euler angles from the parent object to simulate 0. I’ve also messed around with using LateUpdate instead of Update. All to no avail.
I figure that there is a better way of doing this, can anyone let me know what I’m doing wrong? I’m pretty sure that this is a simple thing, and I’m just missing something blindingly obvious.
thanks!