When I set a position to a GameObject
it’s done to its center.
Which is the best way to position a GameObject
relative to it’s bottom. Is there a way to change its anchor point like in cocos2d-iphone
?
When I set a position to a GameObject
it’s done to its center.
Which is the best way to position a GameObject
relative to it’s bottom. Is there a way to change its anchor point like in cocos2d-iphone
?
You could calculate the actual height and width of objects with the help of their mesh and then add this to your center point to get the bottom:
MeshFilter mf = yourgameobject.GetComponent<MeshFilter>();
Vector3 objSize = mf.sharedMesh.bounds.size;
Vector3 objScale = yourgameobject.transform.localScale;
float objHeight = objSize.y * objScale.y (*anyparentobject.transform.localScale.y);
float objWidth = objSize.x * objScale.x (*parent.transform.localScale.x);