hello everyone. So, I am creating a function for moving multiple game units at one time; however, I do not want them all to move to the same tile. I want them to move, keeping their formation. For example, let say that a player has four units in their possession. I want the player to be able to select all four of their units, and select a random tile on the map. The units will then move around the new location, keeping their same box formation with the new location being the center.
I was wondering how some of you would choose to go about this? I was thinking I could cycle through all of the currently selected units, and I find the selected unit farthest to the left, and the selected unit farthest to the right. I then average the two points to find the centered point in between the units. I then calculate the distance between the new desired location, and our averaged location and apply this change to every selected units coordinates. If my explanation is unclear, think of rigid motion transformations. My goal is to basically translate the pre-image made by all selected units. So, if anyone can make any type of sense out of what I just explained, I would be interested to hear your ideas about this. I currently do have a function in coding, but it isn't accurate at all.
Pages 1