I’ve got a perspective camera with a 3D scene. In the scene is just a terrain plane. I’d like to manually position some sprites in this scene so that they are standing on top of the plane. The sprites are at different z values so some are larger in appearance than others.
I’ve tried positioning them with this code but I really am not sure at all about what I am supposed to be doing. I’m looking at details and haven’t gotten an idea for big picture stuff first.
var demBounds = gameObject.GetComponent<SpriteRenderer>().bounds;
gameObject.transform.position = new Vector3(gameObject.transform.position.x, gameObject.transform.position.y + gameObject.GetComponent<SpriteRenderer>().bounds.extents.y, gameObject.transform.position.z);
I’m using prepositioned game objects as spawn points to take care of the X and Z for positioning so I only have to worry about the Y. The terrain is at Y position 0. So in this code I was trying to get a value equal to half the height of the sprite and use that number to offset the sprites position from 0. The sprite, however doesn’t move at all.
Any help is much appreciated.
Thanks!
Oh, here’s a screenshot if it is helpful to anyone.
[35292-sprite+not+flush.jpg|35292]