Okay so I am making a game in which the player places furniture and decorations, inside an “invisible” grid. when rotating the furniture though, the furniture doesn’t rotate as I wish it would, because the objects are not cubes.
This is a Beach chair before rotation:
And this is the chair after I rotate it:
I want it so after I rotate it it would be like so:
Basically:
And not like that:
This is the function in which I create the objects:
public void PlaceObject(float rotation)
{
Vector3 MousePosition = InputManager.GetMapPos();
Vector3Int gridPos = grid.WorldToCell(MousePosition);
Vector3 ObjectPlaceMent = new Vector3(grid.CellToWorld(gridPos).x + DesiredApparatus.Offset[0], DesiredApparatus.AObject.transform.position.y, grid.CellToWorld(gridPos).z + DesiredApparatus.Offset[1]);
Quaternion Rotation = Quaternion.Euler(DesiredApparatus.AObject.transform.rotation.eulerAngles.x, rotation, DesiredApparatus.AObject.transform.rotation.eulerAngles.z);
Debug.Log(Rotation);
if (!DoesCollide(ObjectPlaceMent, DesiredApparatus))
Instantiate(DesiredApparatus.AObject, ObjectPlaceMent, Rotation);
}
I should mention the rotation float the function takes is for the rotation in the Y axis