Getting the geometric position of an object
When you get the position of an object, you actually get the position of the object's center of mass.
In most cases, this is enough, as the center of mass of an object usually corresponds to its geometric center (or centroid). However, in cases where they do not align, and you wish to get the geometric center, getting its position will thus not suffice.
The center of mass of an object is not the same as it's geometric position. The geometric position of an object is the midpoint of the vector between it's minimum and maximum vectors, and is the actual center of an object, which doesn't always correspond to the center of mass of the object.
The trick is to take the Get Position vector and offset it by half the total size of the object. The "total size" of the object refers to the sum of the minimum and maximum vectors of the object.
By extension, to set the geometric position of the object, set the position (center of mass) of the object to the desired position (centroid) subtracted by the offset.
In the example above, the Get Size block returns the minimum and maximum vectors. These are added together, and the result is halved and stored for later in the variable Offset
.
In the next section, the object pointed to by Obj
is set to the desired geometric position ((1,1,1)
) subtracted by Offset
.
In the section after, the object's new position is then queried, and added to the offset to produce the geometric position of the object.