I have a cube and I would like to use addforceatposition and apply this position to the center of a particular cube face in order to make that face turn to face the pulling object.
I do not understand however how to calculate the position of the cubes side for the position attribute of the function. Is this suppose to be a relative position, or am I suppose to get the center of the cube from its position, and then add 1/2 its dimensions to that point to get the particular side while accounting for rotation? Does Unity have some means of calculting the position of that side relatively and then converting it to world coordinates?
A simple way to find the center of a cube face is to use the local references transform.up, right and forward. They are unit vectors, thus you can multiply them by the cube size / 2 and add to the cube position, as you suspected. For instance:
front face center: transform.position + transform.forward * cubeSize/2;
back face center: trasnform.position - transform.forward * cubeSize/2;
left face center: transform.position - transform.right * cubeSize/2;
bottom face center: transform.position - transform.up * cubeSize/2;
and so on. You don’t have to worry about rotation, since these local vectors follow the cube orientation.