- Home /
This question was
closed Aug 29, 2017 at 07:13 AM by
miramaslow for the following reason:
The question is answered, right answer was accepted
Question by
miramaslow · Aug 29, 2017 at 06:39 AM ·
c#transformgrid
The grid won't cover all the area of the wall
No matter how many grids in the game, the grid will resize itself and they won't fill the empty area on the left side of the wall. Below is the illustration of my problem:
Here's the code so far:
sizePlace.y = baseGrid.gameObject.GetComponent<MeshRenderer>().bounds.size.y / sizeGridX;
sizePlace.z = baseGrid.gameObject.GetComponent<MeshRenderer>().bounds.size.y / sizeGridZ;
sizePlace.x = baseGrid.gameObject.GetComponent<MeshRenderer>().bounds.size.x*1.57f;
gridPosition.y = (baseGrid.gameObject.GetComponent<MeshRenderer>().bounds.size.y / 2) - (sizePlace.y / 2);
gridPosition.z = (baseGrid.gameObject.GetComponent<MeshRenderer>().bounds.size.z / 2) - (sizePlace.z / 2);
gridPosition.x = baseGrid.transform.position.x;
startGridPosition = gridPosition;
baseGrid
is the wall surface and Place
is basically a flat cube where I made it as a grid.
I'm not very good at math and stuff so if someone could guide me, I would be glad. Thanks thanks thanks!
grid2.png
(17.0 kB)
Comment
Best Answer
Answer by miramaslow · Aug 29, 2017 at 07:11 AM
Ok what a silly mistake I did, my sizePlace.z
is calculated using baseGrid bound.size.y
instead of bound.size.z
. Problem solved.
sizePlace.z = baseGrid.gameObject.GetComponent<MeshRenderer>().bounds.size.z / sizeGridZ;