Hello everyone!

I have 2 gameObject: an Enemy and a Plane. In Plane I want to show a Texture with a circle.

The problem is: how I scale the plane to the Enemy’s dimension? using scale make a wrong result…

Ps. I’m a newbie… Thanks for all

Hello everyone!

I have 2 gameObject: an Enemy and a Plane. In Plane I want to show a Texture with a circle.

The problem is: how I scale the plane to the Enemy’s dimension? using scale make a wrong result…

Ps. I’m a newbie… Thanks for all

Best you leave enemy scale to 1,1,1 all the time.

Now get the dimensions of the enemy with it’s bounding box.

Depending on what you are trying to do this could be Collider.bounds, Mesh.bounds, Renderer.bounds

With the bounding box dimensions you can scale your plane. Make sure the plane is 1 unitylong and one unit wide,so you do not have to do facy unit conversions. Now wosition the plane and scale scale the X and Z axis. Done!

Hi again!

As I said, you need to check the bounding box of the enemy! There you have the dimensions. With these you can scale the plane accordingly.

```
/* C# */
// Get the enemy dimensions
Vector3 enemyDimensions = enemy.renderer.bounds.size;
// Set the plane scale
myPlane.transform.scale
= new Vector3(enemyDimensions.x, 0.0f, enemyDimensions.y);
```

- For this to work, the plane has to have the dimensions Vector3(1,0,1)
- Make the plane a child of enemy and set it in relative space under the enenmy

I have not tested this (not much time) but it should work this way.

This is my working code:

// I dont' need a Vector3 becouse plane size is (1,1,1) so the "perfect" size // for this is (resValue, resValue, resValue) var resValue : float; function Update(){ var enemySize : Vector3 = enemy.renderer.bounds.size; // planeScaleAxis(1) : resValue = x : enemySizeAxis var planeX : float = enemySize.x / resValue; var planeY : float = enemySize.y / resValue; plane.scale = Vector3(planeX, 0, planeY); }

Thanks for your answers captaincrunch80!!!

The problem is that i don’t know what is the value to assign…

If I manually set the Plane scale to (1, 1, 1) and set the enemy scale to (1, 1, 1), they have different dimensions…

How I can find the “same dimension values”?