# Prepare your 3D Models

## Requirements

* Pivot of the 3D model should be centered in x and z axis
* The 3D model should have a collider attached so we can interact with it after it is placed.
* The Y axis of the pivot point is handled automatically on runtime, no need to worry about that



Most of the used 3D models in this asset already have the correct pivot point.&#x20;

E.g. For the house type 06 the pivot is already on y=0 and centered across the x and z axis.

<figure><img src="https://2246030742-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fco4xXomdydKxUN9bK14I%2Fuploads%2FBZCeVsx7ddaVEZ9TSmLy%2Fimage.png?alt=media&#x26;token=44d3f2dd-dab5-4b19-9da2-b20d24fa4349" alt=""><figcaption></figcaption></figure>

If this is the case for your models you can simply create a prefab out of it and assign it to the proper placeable object.

## P**roblem: Wrong pivot**

Obviously not all 3D Models will use a perfectly centered pivot.

For showcasing the issue I have created an example object with a wrong pivot. As you can see the pivot is not centered in the x and z axis. The y position of the pivot is not even at the bottom of the mesh, so instantiating the object at 0,0,0 position would result in the object being half under the floor.\


<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXf1cekccripRM6IeitOsYLTx-he1kDRxRSdPsexead54eHU28FKwgUtxj0Qw4nMBeXuMav3zajP3TWBkpaVaKVGU6ZlJIfs1y7ktSEn1q5iQ5JIQsNiOOaR4WZWDga_85XAm9me?key=cc_Cn8aGhqTGMuEEmspb992I" alt=""><figcaption></figcaption></figure>

Let’s try out to place this object on the grid:

The left example is without rotation and the right one with rotation applied.

![](https://lh7-rt.googleusercontent.com/docsz/AD_4nXeEtx6VXnW0FzHHlx4zS6K34EBFoCqJMrR1prC9rKUjzX6gwQhTJJgDbLnWOxNHBxICeywrWjMOg-e0Kt0jf3eTMnh_AHMl9riXPEAYDcAB9_7UIS8YOZZtrM-32TnFvVrAQBRvOg?key=cc_Cn8aGhqTGMuEEmspb992I)       ![](https://lh7-rt.googleusercontent.com/docsz/AD_4nXcBFWk_MXw0GAVUSVsg7DsuyKmQXZ-Bm9ITH-oc2f0ogzElYIEivoxIhyfW97gmL6qDB4EWtSHFzjwo2Ql5Omd7kYUdKGDdedQK6ptBJ9MWKfyB3ohwutqxnnKjjElkWR-azoLh0g?key=cc_Cn8aGhqTGMuEEmspb992I)\
\
You can see that the automatic grid pivot offset calculation at runtime perfectly handles the height offset. However if you try to rotate the object you can see that the object is not anymore in the marked grid cells where it actually should be.



## S**olution: Center pivot of your 3D model**

To fix the previously described issue you simply need to create an empty gameobject and add the CenterMeshXZ to this object. Then add the 3D model as a child of this object.

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXeIrm2TnQTsTw-bocW_vpLuhQBzMQfa_p73dM7Kn2xdKkiYXK_d-aaCV_QkDGi8a3ZUK8lfsEr8e9jXT3ndiCYhmDsBIRf5aUUJ2XnLwvDNoCKJeZuFmL9uPpDTa-ZPXkhm3kK8?key=cc_Cn8aGhqTGMuEEmspb992I" alt=""><figcaption></figcaption></figure>

You can simply click on “Center MeshXZ” and the pivot is automatically fixed for you.

However you do not need to use the button,since the script will be executed on runtime which will fix the pivot. The most important thing is just that the script is attached to the parent object.

Now your model is ready to be added to a placeable object and used in the grid system.

{% hint style="info" %}
Please make sure that you have a collider assigned to your model
{% endhint %}
