Hello Guest

Author Topic: Couple of problems(rendering and flipping)  (Read 5975 times)

Noses

  • Newbie
  • *
  • Posts: 1
    • View Profile
Couple of problems(rendering and flipping)
« on: February 14, 2012, 07:27:22 pm »
Hi,
     Good piece of kit, so far. However, have ran into a couple of quirky occurrences Nothing much; maybe a couple of fingers worth if I were a Mafia boss.  I'm not. I'm much worse. That's good for you, since you're beneath my contempt. Anyway.... Any help would be greatly appreciated :D

Sprites appear to oscillate ever so slightly while the player character sprite(and therefore camera) is in motion. It's using a simple smooth follow script. Damping is up full, height 0. Don't know if this is Unity's fault. I suspect it ma be, as planes, without any 2d toolkit scripts attached, appear to do the same thing. Anyone have any advice on this matter? Using Unity 3.5 beta.

Secondly, when rotating sprites in the editor, using the flip horizontal and flip vertical buttons, the sprite breaks. By breaks, I mean it is no longer selectable in the game environment; if you want to edit it you have to click on it in the hierarchy. Secondly, it's positioning, with respect to the snapping grid is completely messed up when the project is closed an restarted. An thirdly, after a seemingly arbitrary number of project close and restarts, the texture just jumps to the first one in the associated sprite container; on all the flipped sprites. All of that holds true if I flip it using the transform on the plane, as well. It doesn't happen to unity planes without the toolkit script, though.

Any ideas as to what is going on?

Thanks

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Couple of problems(rendering and flipping)
« Reply #1 on: February 14, 2012, 08:18:24 pm »
Hi,

Good to hear I'm not a target. Like most people, I prefer not being on anyones hitlist :D

Regarding the sprites oscillating - do you have point sampling turned on? You can often fix this issue by making sure your sprite is snapped to pixel increments.

The problem with flipped sprites is actually expected behaviour - what happens when a sprite is flipped is that its drawn the opposite way around. Unity then thinks the "front" of the sprite is actually on the opposite side to what is seen on screen. This is "fixable" by inverting all the polygons, but this is not foolproof - it will break when the sprite is flipped using the Unity transform widget. The "fix" also requires additional resources to store the inverted indices, and will increase the amount of data written - its far more efficient when it doesn't have to do it. I can advice on what to do to change it, but I recommend against doing that for code used in the game.

I can't explain the texture jumping to the first one though - is it possible to reproduce it? The fliipped value is simply a multiplier - it shouldn't affect what sprite is drawn in any way.

Cheers,
unikron

fkassad

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 17
    • View Profile
Re: Couple of problems(rendering and flipping)
« Reply #2 on: March 21, 2013, 09:20:36 pm »

The problem with flipped sprites is actually expected behaviour - what happens when a sprite is flipped is that its drawn the opposite way around. Unity then thinks the "front" of the sprite is actually on the opposite side to what is seen on screen. This is "fixable" by inverting all the polygons, but this is not foolproof - it will break when the sprite is flipped using the Unity transform widget. The "fix" also requires additional resources to store the inverted indices, and will increase the amount of data written - its far more efficient when it doesn't have to do it. I can advice on what to do to change it, but I recommend against doing that for code used in the game.


This issue makes level creation a little bit more cumbersome if you are flipping sprites a lot.  I have a few different tiles I'm using to make the ground for a level and to vary the look of it, since I'm repeating the same tile, I will flip the tile horizontally. Since it's no longer selectable in the scene view I can no longer quickly select it to place it exactly where I want it.  Any updates to this since this was posted 1 year ago?  Only thing I can think of to quickly select it is inverting the editor camera to select those flipped tiles by hitting the X-axis at the top right of the scene window, and then hitting the z-axis.  This will show the scene I was just looking at from the other side and I can now select all the flipped tiles.  This isn't really that ideal though!

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Couple of problems(rendering and flipping)
« Reply #3 on: March 21, 2013, 10:11:42 pm »
You can set Render Mesh to Double Sided. This will generated a double sided mesh, and this will be clickable both ways. This adds 2 polys per sprite, you could turn it on during development and switch it back when you deploy to your target. If there isn't any noticable performance drop (and you should only notice a performance drop if you have a LARGE number of them), then there shouldn't be any performance drop at all. If this works, then I could probably create a hack for you which will do this automatically and transparently in the editor but never when running the game.
Should be easy enough, and won't affect anything really.

Out of curiosity, how many others find this to be a major problem?

fkassad

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 17
    • View Profile
Re: Couple of problems(rendering and flipping)
« Reply #4 on: March 22, 2013, 12:34:52 am »
No need to create the hack for me.  I will just create sprite collections with double sided render meshes. When I'm ready to build and deploy I can switch it back if I need to.

Thanks

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Couple of problems(rendering and flipping)
« Reply #5 on: March 22, 2013, 05:29:59 pm »
I've added a non-hacky solution for this for the next release, no need to duplicate indices.

fkassad

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 17
    • View Profile
Re: Couple of problems(rendering and flipping)
« Reply #6 on: March 30, 2013, 05:12:46 pm »
Awesome!  Thanks :)