A little Problem about Grid Positioning

Hello everybody,
I have no problem about any code or systematic. I just having problem about my grid misses the center as I go further in Y-axis. I had problems which lesson we adjusted our game area and canvas it’s obviously about it can somebody help me?

04

same problem :frowning:

Hi Neurons,

Now you can see where the centre of each unit should be, e.g. by placing a defender in each square in a column, go back and re-scale the grass until it’s a bitter fit for you. :slight_smile:

Thax For replying Rob.

You see my problem is that i have an instance of a cactus in the scene already and on 0,0 coordinates its position is on the middle point of the lower left block .
But when i create a new instance by dragging the cactus prefab into the scene, the new cactus has also 0,0 coordinates But the position is not the same, its behind on another block of grass which is not the part of the game and also it is not in the middle area of the block .

Hi,

Sorry, I’m not sure I fully understand, could you perhaps include a screenshot, with some annotation perhaps to help explain?

cactus

The cactus on the front side have transform of x=0 and y=0 and its on the right spot where it should be.

But the cactus in the behind (which is the new instance of the cactus prefab) has also the transform of x=0 and y=0 but its position in the world point is not right.

Both cactuses positions should be same.

Hi,

I can’t tell which is front side and which is in the behind ?

Can you select each cactus, one at a time, and take a screenshot of the Inspector details for it, e.g. so we end up with two sets of Inspector details, one for the cactus on the left, and one for the cactus on the right.

Could you zip up your project and share it so that I can take a look? It might be something simple like you have child game objects of the main game object and the children have not had their transforms reset.

The forum will allow uploads of up to 10MB, if your project files (zipped) are larger than that you would need to use a service such as Google Drive or Dropbox, and then share the URL.

okay i’m uplodaing my file to Drop Box, its size is 30 mb.

Ok, just share the URL with me when you’re ready and I’ll take a quick look.

1 Like

Here is the link Rob : https://www.dropbox.com/s/7vf316idx31lmpq/GlitchGarden.rar?dl=0

Grabbing it now, give me a few minutes to convert/open the project and take a look, I’ll post back after.

1 Like

when you play the game , Add the new Defenders by using the above Deffender Buttons in the game and then notice the positions and colliders of those Defenders game objects clones.

Hi,

The cactus that you have in the bottom left hand corner has a transform position of 0, 0, -0.25. These values are in bold, this indicates that it is different from the prefab, so you have obviously positioned this one yourself.

The other cactus has a transform position of 0, 0, 0, and it’s in a different location because it is a child of the Defenders GameObject, which has a transform position of 0.8894865, 0.5761878, -0.009080214.

So, that explains why they are in different locations.

With regards to your next point, about playing the game and seeing their positions, the parent Cactus game objects are set correctly, any offset that you are unhappy with can be corrected by changing the transform of the child body game object within the prefab.

Does the above make sense and help?

image

The above screenshot is from deleting the two cacti that you had in the scene before running the game.

Then changing the transform of the body game object within the cactus prefab;

image

…so that it had X and Y at 0;

image

Then on the Cactus prefab itself;

image

…the collider had its offset for X and Y set to 0 also, which aligns the collider to the square of the grass (roughly);

image

i appreciate your help rob, but i tried my best from 2 hours working on this problem , but im not able to solve this problem … can you please edit my file and upload it to the dropbox and send me the link please.!!

Problem : When i click on Defenders button and then click on a block of grass , the defender spawns on the wrong spot…?

Follow the steps in my reply above, that will resolve the issue for you :slight_smile:

The screenshot is from your game.

Thanks man the problem is solved but dont know how :stuck_out_tongue:

Did you make the changes above?

yes, Problem is solved, i dont know why the already available defenders instances in the scene were causing problem. i make another instances by dragging the prefabs and make changes to the body gameobject and the parent collider and applied it, and now the clones are on the right positions when spawned

1 Like

Thanks mate , this problem was killing me, but thanks to you its solved now :slight_smile:

1 Like

It was all down to the offsets that had been created by the child game objects.

As an example, if you place a cube at 0, 0, 0 and then add another cube, make it a child of the first cube, and set its transform to 0, 10, 0, you’ll see that the child cube is way up above the parent cube. You can move the parent cube around and the child cube will following, but it will always be 10 units above the parent cube.

Silly example, but one that may help demonstrate the parent/child relationship with their transforms.

Thanks mate , this problem was killing me, but thanks to you its solved now :slight_smile:

You’re very welcome, happy to help :slight_smile:

Privacy & Terms