- Home /
How to check if object is skewed ?
Hi guys... i need some check for objects are they skewed...
My first idea was to check if local scale is equals to lossy scale, but i remembered that in group local scale multiplies to parent local scale... may be here we can do something like transform points... but i can't get whole image of solution, can you help me ?
Hmm.. i got new idea..
if (t.lossyScale == (t.TransformPoint(t.localScale)-t.position))
i'v tired.. tomorrow will check.. guys, any other ideas, or check this please ?
next my idea was Vector3.Dot(t.localScale.normalized, t.lossyScale.normalized) > (1.0f - Vector3.kEpsilon)
but it not working for grouped object, and fine for simple... thinking....
Answer by XienDev · Dec 15, 2012 at 09:14 AM
Ok, i've found another solution that doesn't requared check for skewness... but the question is staying up..
Answer by ratneshpatel · Dec 21, 2019 at 08:40 AM
Here is how:
// Create a skew vector
Vector3 skew = transform.localScale; // scale of the transform for which you want to check if skewed
// Then iterate through all the parent transforms and do scalar multiplication
Transform parentTransform = transform.parent;
while(parentTransform != null)
{
skew = new Vector3(parentTransform.scale.x * skew.x, parentTransform.scale.y * skew.y, parentTransform.scale.z * skew.z);
parentTransform = parentTransform.parent;
}
// If the final skew is not equal to transform.lossyScale then the object is skewed
bool isSkewed = (skew != transform.lossyScale);
Your answer
Follow this Question
Related Questions
Colored Voxel Meshs 2 Answers
Instantiate in Editor 1 Answer
Paint on object in editor and return as texture. 1 Answer
A node in a childnode? 1 Answer
Player damage stops working over time 0 Answers