Adam's Lair Forum

game development and casual madness
It is currently 2018/09/19, 19:42

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: 2016/07/25, 19:59 
Novice Member
Novice Member

Joined: 2016/06/17, 18:11
Posts: 20
Role: Observer
Hello.

1) Rect values
The Sprite Renderer uses a Rect struct to do voodoo magic.
The normal values are -128.0, -128.0, 256.0, 256.0.
The description in the Advisor says:
"The rectangular area the sprite occupies. Relative to the GameObject."
I still don't get though what those values are doing, when I change the values the results aren't random but I don't know what's going on.

2) Displaying different heights in an isometric world
This is really confusing to me. @w@
The z-value of the Transform Postion of each Tile seems to be helpfull when dealing with overlapping of objects. (house in foreground (z = -0.01) hides house in background (z = 0))

Image

But I don't know how to display tiles, to be on a hill, without changing their x,y coordinates.
The result should kinda look like this.

Image

Thanks.


Top
 Profile  
 
PostPosted: 2016/07/26, 10:43 
Forum Addict
Forum Addict
User avatar

Joined: 2013/09/19, 14:31
Posts: 879
Location: Italy
Role: Hobbyist
Let's see if I can explain myself ^^

Senpai91 wrote:
The Sprite Renderer uses a Rect struct to do voodoo magic.
The normal values are -128.0, -128.0, 256.0, 256.0.
The description in the Advisor says:
"The rectangular area the sprite occupies. Relative to the GameObject."
I still don't get though what those values are doing, when I change the values the results aren't random but I don't know what's going on.

First of all, the Rect structure used by the SpriteRenderer is not voodoo magic :mrgreen:
as you know, the structure is composed by X, Y, Width and Height value.

Starting from the easy part, Width and Height basically represent the size of your SpriteRenderer - how big and how squished is the image once you render it on screen.

X and Y, on the other hand, represent where the Sprite is drawn, relative to your GameObject; remember that the GameObject is sizeless, and at most it is identified by a Transform Component. So, if you were to use [0,0] as X,Y, you would simply tell the SpriteRenderer to start drawing in that position - that is, place the TopLeft corner of your image exactly where the GameObject's Transform is.
If you were to want your Sprite centered on the GameObject, instead, you should use [-Width/2, -Height/2] as your X,Y coordinates :)


Senpai91 wrote:
2) Displaying different heights in an isometric world
This is really confusing to me. @w@
The z-value of the Transform Postion of each Tile seems to be helpfull when dealing with overlapping of objects. (house in foreground (z = -0.01) hides house in background (z = 0))

But I don't know how to display tiles, to be on a hill, without changing their x,y coordinates.
The result should kinda look like this.

Well, an isometric projection is a kind of 3D projection, so of course you will have to change X and Y coordinates to be able to map it to a 2D screen :)
In particular, you already noticed that Z helps in dealing with overlapping; this is because Z controls how far from the camera your GameObject is. Of course, nearer objects get drawn in front of farer (does it exist? :wtf: ) ones. What you can also use, is the Offset property, which is used exactly to determine which GameObject, between all those sitting at the same Z, should go in the front.

All this said, you should be able to calculate the position of your isometric object in 2d Screen Coordinates, keeping in mind that objects in front should have a higher Y compared to those in the background, but that Y is also affected by the height of the object itself - you could end up with a sprite at a Screen Y position which is lower (thus "higher" in appearance) than an object that sits behind it.

And in any case, you can use the Offset set row-by-row to help with the overlapping of the various Sprites.

Maybe that last part is a little convoluted.. it's quite clear in my head but I'm not sure what I wrote is as well :mrgreen:

Good luck ^^

_________________
Come on Duality's Discord channel. We have cookies! :mrgreen:


Top
 Profile  
 
PostPosted: 2016/07/26, 15:30 
Member
Member

Joined: 2015/12/27, 00:33
Posts: 76
Role: Hobbyist
It's "farther" ;)


Top
 Profile  
 
PostPosted: 2016/07/26, 15:59 
Forum Addict
Forum Addict
User avatar

Joined: 2013/09/19, 14:31
Posts: 879
Location: Italy
Role: Hobbyist
ChatPion wrote:
It's "farther" ;)


I knew I was missing some letters :rly:

_________________
Come on Duality's Discord channel. We have cookies! :mrgreen:


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group