Comments and answers for "Object´s scale is decreasing less than expected"
http://answers.unity.com/questions/1611850/objects-scale-is-decreasing-less-than-expected.html
The latest comments and answers for the question "Object´s scale is decreasing less than expected"Comment by Feref2 on Feref2's comment
http://answers.unity.com/comments/1613940/view.html
Even then, the script only subtracts that value once the object moves to the place where they start colliding. So it doesn´t matter if they are not phisically colliding. After that point, it just subtracts how much is moving and then a raycast does detect how much is going through and subtracts again, but isn´t enough. The ray measures like this: hit.distance - skinwidth (skinwidth is how far is from the edge). So if the hit.distance is < skinwidth, is going through.Tue, 19 Mar 2019 05:31:32 GMTFeref2Comment by Sibz9000 on Sibz9000's comment
http://answers.unity.com/comments/1612644/view.html
> //here´s the thing: even though the ray value should be 0 (if the object is perfectly colliding at the edge and isn´t going through) is something like -0.002...
I believe that collisions only occur once they pass through, objects perfectly on edge are not considered collided. So after a collision there will be always be value of passing through.Thu, 14 Mar 2019 22:51:04 GMTSibz9000Comment by Feref2 on Feref2's comment
http://answers.unity.com/comments/1612200/view.html
float uScale = grounds[i].transform.localScale.x * groundScripts[i].originalScale.x;
//groundScaleX[i] is first calculated. Is the final ground.
groundScaleX[i] = (groundScaleX[i] - uScale) / 2;//Now changes to the half of how much is decresing or increasing from the current scale (am recycling variables to avoid garbage) for example (3 -5) / 2 = -1 is decreasing (the half is because the other object decreases the other half);
Vector3 newScale = grounds[i].transform.localScale;
newScale.x = (uScale + groundScaleX[i]) / groundScripts[i].originalScale.x;
grounds[i].transform.localScale = newScale;
//the object that moves is connected to this ground (the floor´s reduction is what causes it to move). Logically speaking, it moves the groundScaleX[i] value.
Then there´s the other script which makes this:
currentX = transform.localScale.x * originalScale.x + leftRay.extra + allSizes.groundScaleX[leftGroundId]; //here am adding an extra ray from other script that measures how much is going through. This almost completely get rid of the issue, but that ray is thrown before.
//here´s the thing: even though the ray value should be 0 (if the object is perfectly colliding at the edge and isn´t going through) is something like -0.002..., but not constant. Subtracting this number really helps, but after some frames the issue appears again. I think this is because the ray shows how much ended up going through at the end of the previous frame. Throwing the ray after is complicated since I must calculate every position for the ray to be accurate, and after that, recalculate all grounds, which leads to recalculating this as well and is not good for performance, speacially because of how large the operation really is. Then the ray value from before - how much is decreasing should, logically, tell me this without needing to positionate everything beforehand. This was my original intention with the code line above, but again, for some reason the object needs to decrease more than the groundScaleX[i], which shouldn´t in the first place.Wed, 13 Mar 2019 19:42:58 GMTFeref2Comment by Sibz9000 on Sibz9000's comment
http://answers.unity.com/comments/1611945/view.html
Oh right, sometimes code really helps. If you can, post the important lines of what you are doing.Wed, 13 Mar 2019 08:41:52 GMTSibz9000Comment by Feref2 on Feref2's answer
http://answers.unity.com/comments/1611878/view.html
Sorry, I forgot to mention that am doing this (transform.localScale.x * originalSize.x - moveUnit) / originalSize.x;
That way I get the correct number and translate it into the transform Scale.Tue, 12 Mar 2019 23:41:12 GMTFeref2Answer by Sibz9000
http://answers.unity.com/answers/1611851/view.html
Scale is not number of units, it's a multiplication of size.
If your object, lets say cube for simplicity is 1x1x1, then a scale of 10 makes it 10x10x10
However if its 1.2x1.2x1.2, then a scale of 10 makes it 12x12x12.
So if we remove 4 from the scale of the first example, we get the expected size 6x6x6.
However in the second example we get 7.2x7.2x7.2 - not 8x8x8 as you may think.
If we have a smaller than 1 size, lets say 0.8x0.8x0.8 then the decrease would be less:
0.8x0.8x0.8 scaled by 10 = 8x8x8
Minus 4 from scale = 0.8x0.8x0.8 scaled by 6 = 4.8x4.8x4.8
The result is a size reduction of only 3.2, less than the 4 you would expect if thinking that scale is size.Tue, 12 Mar 2019 22:02:34 GMTSibz9000