Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
roomforthetuna
Mar 22, 2005

I don't need to know anything about virii! My CUSTOM PROGRAM keeps me protected! It's not like they'll try to come in through the Internet or something!

SlightlyMadman posted:

Oh yeah, absolutely, I was just wondering at that point if it might be better to use each plane to represent 100 squares of my grid, effectively lowering the resolution on terrain while still allowing individual squares to be manipulated by the game.
Ahhh, right. That's a good thing to wonder, and goes with the thing I was saying earlier too for someone doing 2D - I'm of the opinion that if you're doing a tilemapped scrolling game, you should use some sort of a Tilemap class that handles the whole thing in one GameObject (except possibly collisions being broken down into simple chunks of appropriate size) for the reasons your test code has now demonstrated - initializing hundreds-by-hundreds of GameObjects is just asking for poor performance.

On the downside of doing things like that in one big object, you have to do a lot more of the work yourself, you're kind of throwing all the engine's hand-holding out the window. But not in the case of Terrain because that class is already in there with all the requisite hand-holding!

roomforthetuna fucked around with this message at 22:52 on Apr 6, 2013

Adbot
ADBOT LOVES YOU

Orzo
Sep 3, 2004

IT! IT is confusing! Say your goddamn pronouns!
By the way, SlightlyMadman, it probably won't matter too much for what you're doing, but jagged arrays are generally preferable over multidimensional ones (i.e. myArray[x][y] vs myArray[x, y]) in terms of performance. See this post.

Edit: I see that one of the comments specifically mentions that the performance comparison might be different on mono, which is what mono uses. So maybe I am wrong. If managing a huge grid of things is ever a bottleneck, it's probably best to try both ways!

SlightlyMadman
Jan 14, 2005

Orzo posted:

By the way, SlightlyMadman, it probably won't matter too much for what you're doing, but jagged arrays are generally preferable over multidimensional ones (i.e. myArray[x][y] vs myArray[x, y]) in terms of performance. See this post.

Edit: I see that one of the comments specifically mentions that the performance comparison might be different on mono, which is what mono uses. So maybe I am wrong. If managing a huge grid of things is ever a bottleneck, consider both ways as options!

Huh, that's interesting, I'd never heard that. But yeah, this only needs to be generated once per game, so no big deal, and the TerrainData class is taking a multidimensional array in function call, so if I used jagged arrays for the generation, I'd still have to convert it into a multidimensional array before I could use it.

By the way, I messed around with my noise settings and I'm suddenly not getting anything. I'm sure I just broke it somehow, but I can't figure it out. Is there a console I can write output to for debugging?

roomforthetuna
Mar 22, 2005

I don't need to know anything about virii! My CUSTOM PROGRAM keeps me protected! It's not like they'll try to come in through the Internet or something!

SlightlyMadman posted:

By the way, I messed around with my noise settings and I'm suddenly not getting anything. I'm sure I just broke it somehow, but I can't figure it out. Is there a console I can write output to for debugging?
Debug.Log()

Unormal
Nov 16, 2004

Mod sass? This evening?! But the cakes aren't ready! THE CAKES!
Fun Shoe

Just be wary that the debug.logx functions are unbelievably slow. For one-off printf-style debugging, they're perfectly good; but they'll obliterate your frame-time if you leave them in for testing.

This is a pretty nice drop-in debug console using OnGUI:
https://gist.github.com/darktable/1412228

Orzo
Sep 3, 2004

IT! IT is confusing! Say your goddamn pronouns!

SlightlyMadman posted:

Huh, that's interesting, I'd never heard that. But yeah, this only needs to be generated once per game, so no big deal, and the TerrainData class is taking a multidimensional array in function call, so if I used jagged arrays for the generation, I'd still have to convert it into a multidimensional array before I could use it.
Oh, my bad then, I didn't know that their API required that.

One Eye Open
Sep 19, 2006
Am I awake?
Just a little aside to Unity terrainchat - if you dynamically change the terrain after instanciation, remember to call Terrain.Flush() afterwards. It may seem obvious, but it caught me out once.

Orzo
Sep 3, 2004

IT! IT is confusing! Say your goddamn pronouns!
I don't normally post my work here since I already post updates in two other threads, but my latest update gets into some technical details and stuff, so I wanted to share here too.

Blog post is here.

Showing the player getting hit, and hitting back:
https://www.youtube.com/watch?v=vJ4rsD0SQqw&hd=1

Showing how the sword is implemented by turning a normally invisible entity on:
https://www.youtube.com/watch?v=2QHfgFoEoaI&hd=1

Unormal
Nov 16, 2004

Mod sass? This evening?! But the cakes aren't ready! THE CAKES!
Fun Shoe

Orzo posted:

I don't normally post my work here since I already post updates in two other threads, but my latest update gets into some technical details and stuff, so I wanted to share here too.

Blog post is here.

Showing the player getting hit, and hitting back:
https://www.youtube.com/watch?v=vJ4rsD0SQqw&hd=1

Showing how the sword is implemented by turning a normally invisible entity on:
https://www.youtube.com/watch?v=2QHfgFoEoaI&hd=1

What's with the Sequence/Range/delegate pattern you've got going there? That looks cool/useful. Is it some standard controller pattern with a write-up somewhere?

Shalinor
Jun 10, 2002

Can I buy you a rootbeer?
Mug mentioning his mod tools over in the Greenlight thread got me wondering... do you suppose people would dig a Unity game that released its source?

I don't want to make my own mod tools, but realistically, Unity as-is is a better "mod tool" than I'd ever make anyways. The only big question would be how to handle the assets (ie. you can make mods that sit in the existing game hierarchy, not stand alones), but I think I could solve that with asset packages. IIRC, you can design those to be externally linked - so I'd just ship with one big one, which'd sit in the hierchary, and any mods could add new ones.

Granted, this wouldn't allow for easy merging of multiple mods into one game. I'd also need to stay away from certain Unity Pro-only features, if I wanted average users to be able to compile it. It would really only be useful for total conversion-style new campaign/story things. But would that be "enough" to tickle the types of players that dig mod tools? (In my case, picture a game more like Metroid or whatever - not a free roaming open world RPG)

I'm curious for thoughts on moddable Unity games in general. It seems like something no one's really done much with, yet.

Shalinor fucked around with this message at 03:51 on Apr 7, 2013

SlightlyMadman
Jan 14, 2005

What's the best way to use the water assets? I've loaded in the Standard Assets with Simple Water prefabs, and I'm able to add it to the map as a prefab, but it's difficult to fit into my maps since it's circular and I'm using a grid. I considered just scaling a single instance beneath the entire map so it would be revealed whenever the terrain drops below a certain Y axis, but I think that will cause its surface texture to be stretched.

roomforthetuna
Mar 22, 2005

I don't need to know anything about virii! My CUSTOM PROGRAM keeps me protected! It's not like they'll try to come in through the Internet or something!

SlightlyMadman posted:

What's the best way to use the water assets? I've loaded in the Standard Assets with Simple Water prefabs, and I'm able to add it to the map as a prefab, but it's difficult to fit into my maps since it's circular and I'm using a grid. I considered just scaling a single instance beneath the entire map so it would be revealed whenever the terrain drops below a certain Y axis, but I think that will cause its surface texture to be stretched.
I've never used it, but two thoughts:
1. try scaling it and see how it looks, don't just assume!
and 2. Google it -> "unity water assets" -> http://docs.unity3d.com/Documentation/Manual/HOWTO-Water.html -> you can attach it to whatever mesh you want so you should be able to easily make it fit your grid.

SlightlyMadman
Jan 14, 2005

roomforthetuna posted:

I've never used it, but two thoughts:
1. try scaling it and see how it looks, don't just assume!
and 2. Google it -> "unity water assets" -> http://docs.unity3d.com/Documentation/Manual/HOWTO-Water.html -> you can attach it to whatever mesh you want so you should be able to easily make it fit your grid.

Thanks, I haven't figured out how to animate it yet so I can't really see the texture, but when I googled it before I found this article which is what said not to stretch it too much:
http://answers.unity3d.com/questions/55153/unity-water-help.html

I'll give it a shot anyways once I've worked it out though.

edit: That's funny, reading through the advanced techniques in that article, it seems like it's suggesting I go back to using planes.

SlightlyMadman fucked around with this message at 05:42 on Apr 7, 2013

Orzo
Sep 3, 2004

IT! IT is confusing! Say your goddamn pronouns!

Unormal posted:

What's with the Sequence/Range/delegate pattern you've got going there? That looks cool/useful. Is it some standard controller pattern with a write-up somewhere?
It's some pattern I made up, but it's not too complex so I imagine someone has done something similar before. I have found it quite useful so far. This video is a bit older but shows some of the different ways it can be used. There's no documentation or anything, but basically each Entity has a collection of named IEntityController instances which have have a single method, Update, that returns a bool indicating that the controller is 'done', at which point it deletes itself. Setting a controller on an entity either appends it or replaces one with the same name if it exists. There are a few implementations of IEntityController

* Range, which either loops from start to finish or zigzags back and forth, lasts for a certain duration (or forever), iterates N times, and executes on a number of Interps, each of which specify a property to change, start and end values, and an interpolation curve (linear, sinusoidal, ease in, etc). The video does a good job of showing a bunch of these.
* Execute, which just runs an arbitrary function. You'd typically use one of these in a Sequence
* Delay, which waits n seconds
* Sequence, which combines any number of IEntityController

roomforthetuna
Mar 22, 2005

I don't need to know anything about virii! My CUSTOM PROGRAM keeps me protected! It's not like they'll try to come in through the Internet or something!

SlightlyMadman posted:

edit: That's funny, reading through the advanced techniques in that article, it seems like it's suggesting I go back to using planes.
Yeah, for water that makes sense if you can't stretch it too much.

OneEightHundred
Feb 28, 2008

Soon, we will be unstoppable!

Shalinor posted:

It would really only be useful for total conversion-style new campaign/story things.
I'm not really familiar with how Unity handles asset loading, but a substantial chunk of modding interest is in making changes that work with the existing content because it means there are more things for the new mod content to have novel interactions with. If someone makes a multiplayer game mode, for example, that'll automatically provide a lot of new experiences in just the stock maps, as well as any new maps players get.

Allowing multiple mods to work together is probably much less important, and TCs often springboard off of the interest developed from smaller projects.

Lazerbeam
Feb 4, 2011

I have a few questions regarding game making libraries for python (not sure if this belongs here or the python thread). After learning how to use python 3 I moved onto pygame and I'm loving it, but I'm wondering if it's really the best tool for 2D game development with python. I've heard that pyglet may be a better option because it uses OpenGL and not SDL, but I'm not sure what the pros and cons are.

So my questions are:

1) Should I use pyglet instead and why, and does it matter that the python 3 version is in alpha?
2) Is there something else that would be much better?
3) Should I just shut up and enjoy pygame?

Thanks

SlightlyMadman
Jan 14, 2005

I went through the exact same dilemma, and made several prototypes with both. PyGame is the most straightforward and flexible library out there, and it's ultimately what I've always ended up using. Pyglet is really cool though, and has a lot of advanced functions that PyGame lacks. Basically what it came down to for me, is Pyglet is great for arcade-style games. It has some really advanced and efficient sprite manipulation, so if you have a lot of sprites you need to move and scale at high FPS, like in a shmup or something, it will be much easier to work with and perform a lot better. If you're doing something like an RPG though, PyGame is a much more advanced and mature library, and will probably suit you better.

I'd say go through tutorials with both though, and try out a few simple games, to see which you like best. I personally found it to be PyGame, but I don't really do action games.

Lazerbeam
Feb 4, 2011

Thanks for the reply! :) I've got both RPGs and action games in mind so I guess I'll learn pyglet too.

SlightlyMadman
Jan 14, 2005

My terrain generation is pretty close to how I want it, although I'm having trouble with the smoothing the terrain seems to be trying to apply. The effect I'm going for is something like the SimCity 2000 terrain with angled tiles for slopes:

One Eye Open
Sep 19, 2006
Am I awake?
For those that are interested, Emil Persson has just put his GDC talk up on his website - Low-Level Thinking in High-Level Shading Languages. It's a good read (although I'd prefer fewer memes), and shows that those of us who grew up hand-optimising code(especially assembly) still have a chance to do it.

SupSuper
Apr 8, 2009

At the Heart of the city is an Alien horror, so vile and so powerful that not even death can claim it.

SlightlyMadman posted:

My terrain generation is pretty close to how I want it, although I'm having trouble with the smoothing the terrain seems to be trying to apply. The effect I'm going for is something like the SimCity 2000 terrain with angled tiles for slopes:


If it makes you feel better, those strange stepped hills immediately gave me SimCity 2000 vibes. :v: Give it some diagonals and you're set.

SlightlyMadman
Jan 14, 2005

SupSuper posted:

If it makes you feel better, those strange stepped hills immediately gave me SimCity 2000 vibes. :v: Give it some diagonals and you're set.

It actually does have diagonals, but Unity's terrain weirdly softens things out until you zoom in super close.

'ST
Jul 24, 2003

"The world has nothing to fear from military ambition in our Government."

SlightlyMadman posted:

My terrain generation is pretty close to how I want it, although I'm having trouble with the smoothing the terrain seems to be trying to apply. The effect I'm going for is something like the SimCity 2000 terrain with angled tiles for slopes:
I worked on a similar type of terrain engine in Unity. One thing I discovered is that there are several assumptions in the Unity terrain component about scale. Specifically, it expects that you're making some kind of first- or third-person game where your character is tiny in comparison to the terrain. As a result, it uses level of detail assumptions based on making distant terrain less accurate but faster to render. For top-down games, those assumptions don't make any sense.

The first thing to try is to scale down your terrain and mess with the level of detail parameters in your terrain object. For example, if your terrain's world size is currently 1024x1024 world units, try making it something like 10x10 world units. If the terrain is physically smaller and the camera is always close to the terrain, you will get much less automatic level of detail behavior. Once you gain a better understanding about what Unity is doing, you can experiment with values and settings that make a good compromise between convenience, aesthetics, rendering speed, etc.

SlightlyMadman
Jan 14, 2005

Oh, yeah that's a good idea. So I'd basically change it to work with hundredths of units instead of individual units? Are there any disadvantages to doing this? Here it is with everything scaled down to a 200x200 terrain instead of 2000x2000. I think it does look better:

Chunderstorm
May 9, 2010


legs crossed like a buddhist
smokin' buddha
angry tuna
So I'm having some more trouble, yay!

I found I was having trouble faking battle animations, presumably because nothing involving moving was called in update. So I essentially made update hold the different states of battle (after giving my entire code a re-write), with this being the one for moving:

code:
if (staticVariables.turnState == 2) // moving character for melee attack
{
	// call move toward method, passing in two objects
	statHolder s;
	s = staticVariables.attackTarget.GetComponent<statHolder>() as statHolder;
		
	staticVariables.attackUser.transform.position = Vector3.Lerp(transform.position, s.meleeTarget.transform.position, smooth);
}			
The gameObject I want to move just jumps instantly to the end point, rather than gliding along. What can I do to fix this? Vector3.MoveToward gives me the same result.

Explanations as far as stuff I've defined:
meleeTarget is a child gameObject that gets defined in statHolder. attackUser and attackTarget are static gameObjects that get declared null after each turn. They're just temporary to make it easy to assign which battler is attacking and who it's targeting, then pull that into this bit of code.

staticVariables is just a class I made to hold some values that need to be accessed outside of the battle or across all scripts inside the battle. Testing this with a non-static class, I got the same result.

e: I also tried a while loop but that crashed Unity, presumably because I hosed with update. Is there like, conditional update?

e2: FIXED! Got some help at my school's lab. The code now looks like this, with MeleeMoveToward called at state 2, damage/attack animations in state 3, and MeleeMoveBack in state 4:

code:
public void MeleeMoveToward()
{
	statHolder s;
	s = staticVariables.attackTarget.GetComponent<statHolder>() as statHolder;
	
	staticVariables.attackUser.transform.LookAt(staticVariables.attackTarget.transform); 
	
	if(Vector3.Distance(staticVariables.attackUser.transform.position,staticVariables.attackTarget.transform.position) > 2)
	{
		staticVariables.attackUser.transform.position = Vector3.MoveTowards(staticVariables.attackUser.transform.position, s.meleeTarget.transform.position, smooth);
	}else
	{
		staticVariables.turnState = 3;
	}
}

public void MeleeMoveBack()
{
	statHolder s;
	s = staticVariables.attackUser.GetComponent<statHolder>() as statHolder;
	
	staticVariables.attackUser.transform.LookAt(s.defaultPos.transform); 
		
	if(staticVariables.attackUser.transform.position != s.defaultPos.transform.position)
	{
		staticVariables.attackUser.transform.position = Vector3.MoveTowards(staticVariables.attackUser.transform.position, s.defaultPos.transform.position, smooth);
	}else
	{
		staticVariables.turnState = 5;
	}
}

Chunderstorm fucked around with this message at 23:09 on Apr 8, 2013

Orzo
Sep 3, 2004

IT! IT is confusing! Say your goddamn pronouns!
2D engine question:

Is there any hope for reconciling the following requirements with respect to layering?

(A) Sprites are grouped by layer and then within that layer are sorted by lowest Y coordinate. i.e. if a player is 'below' of a tree's trunk, they are drawn over it, but they are behind it if they are 'above' the trunk.

(B) Batching renders by texture (texture atlas) for performance

Seems impossible, but maybe I'm missing something. There's sort of a (C) where a depth buffer is used, but I also have transparency requirements that might act weird with that.

OneEightHundred
Feb 28, 2008

Soon, we will be unstoppable!

Orzo posted:

2D engine question:

Is there any hope for reconciling the following requirements with respect to layering?

(A) Sprites are grouped by layer and then within that layer are sorted by lowest Y coordinate. i.e. if a player is 'below' of a tree's trunk, they are drawn over it, but they are behind it if they are 'above' the trunk.

(B) Batching renders by texture (texture atlas) for performance

Seems impossible, but maybe I'm missing something. There's sort of a (C) where a depth buffer is used, but I also have transparency requirements that might act weird with that.
If all of the sprites are in the same atlas, you shouldn't have a problem.

If that's not the case, depth buffer fully-opaque ones, see if you can develop exclusion rules (i.e. "the tile layer never has overlaps"), and if you can't, possibly use a screen-space partitioning scheme (i.e. a low-resolution occupancy grid) to detect sprites that couldn't possibly be overlapping another one.

Orzo
Sep 3, 2004

IT! IT is confusing! Say your goddamn pronouns!

OneEightHundred posted:

If all of the sprites are in the same atlas, you shouldn't have a problem.

If that's not the case, depth buffer fully-opaque ones, see if you can develop exclusion rules (i.e. "the tile layer never has overlaps"), and if you can't, possibly use a screen-space partitioning scheme (i.e. a low-resolution occupancy grid) to detect sprites that couldn't possibly be overlapping another one.
Hmm... well, there's definitely no guarantee that any of them will be on the same atlas, so that's out.

The exclusion rule is probably impossible too due to the dynamic nature of the entities I'm working with (the API against the engine can do anything it wants with any tile or entity at any time).

Your suggestion of using the overlapping-detector is probably the best option, but I think I have an even simpler one given my requirements. Since these 'overlapping' draw bugs are of a non-critical nature (i.e. they won't affect the game logic, just the appearance) and generally only apply to a small subset of entities (the player, enemies, etc.), I think I'll make an explicit flag that can be set on entities to mark them as 'batch breakers'--that is, when sweeping through y-sorted sprites to bucket them by texture (which is potentially an atlas), a 'batch breaker' (like the player) will signify that a new set of buckets needs to be created.

So, example case, there are 100 trees and a player, presumably on different atlases:

1. Sort quads by min(vertex => vertex.Y), 45 trees are above player and 55 below
2. Assume they're all on the same layer
3. Start iterating over all 101 quads, batching each quad into a dictionary depending on its texture
4. If you hit a 'batch breaker' texture, like the player, go ahead and draw everything so far. So, draw the first 45 trees.
5. Draw the batch breaker (player, in this case) and then continue.
6. Continue, which will draw 55 more trees on top of the player.

Step 4 can probably be optimized in the way you pointed out--namely, you might not need to dump all of the buckets, depending on collision. For example, two sprites in the top left corner and bottom right corner of the screen (pretend the player is in the middle) would certainly not need to be un-batched!

HappyHippo
Nov 19, 2003
Do you have an Air Miles Card?
How important is requirement B? Are you really running into performance issues rendering sprites?

Orzo
Sep 3, 2004

IT! IT is confusing! Say your goddamn pronouns!
I'll do a performance comparison later tonight with and without batching, but it is almost certainly a non-trivial optimization, especially when rendering thousands of sprites.

Polio Vax Scene
Apr 5, 2009



The problem is that you're rendering thousands of sprites.

Are you rendering things not on the screen?
Can you repeat the sprite texture for walls, floors, etc?

Orzo
Sep 3, 2004

IT! IT is confusing! Say your goddamn pronouns!

Manslaughter posted:

The problem is that you're rendering thousands of sprites.

Are you rendering things not on the screen?
Can you repeat the sprite texture for walls, floors, etc?
Rendering thousands of sprites is extremely common in games, especially when you have any sort of particle effects whatsoever. Batching draws by texture is also almost universally common. This isn't some kind of weird obscure optimization I'm doing. Also, no, I'm not rendering things off-screen.

I could probably write something to merge tiles of same-textured floors/walls, but it's an optimization I don't really feel like doing until it's required, as it's a bit more complex. Also, tiling a texture means you can't use it in a texture atlas without a custom shader to handle overflowing texture coordinates, so there's yet another complexity I don't want to deal with if I don't have to.

roomforthetuna
Mar 22, 2005

I don't need to know anything about virii! My CUSTOM PROGRAM keeps me protected! It's not like they'll try to come in through the Internet or something!

Orzo posted:

2D engine question:

Is there any hope for reconciling the following requirements with respect to layering?

(A) Sprites are grouped by layer and then within that layer are sorted by lowest Y coordinate. i.e. if a player is 'below' of a tree's trunk, they are drawn over it, but they are behind it if they are 'above' the trunk.

(B) Batching renders by texture (texture atlas) for performance

Seems impossible, but maybe I'm missing something. There's sort of a (C) where a depth buffer is used, but I also have transparency requirements that might act weird with that.
One simple-ish option would be to dynamically generate a new single texture atlas from all the others on startup (or level beginning if there are different textures in different areas). Then rule B becomes moot.

Another would be to use Z-buffers to obey rule A, then the code can focus on rule B, but that could have problems with semi-transparent things - unless you put all the semi-transparent things into a single atlas and make sure that's the last atlas rendered, ordered by rule A.

A third option would be to just obey B when it doesn't interfere with A, and then not worry about the fact that you're not 100% obeying B. Chances are your atlases are most likely to be approximately grouped by layer anyway (eg. floors in one atlas, people in another) so you'll mostly get good batching compliance with just a "sort by layer then y" approach, unless you're going with one sprite per texture. And a little bit of unnecessary texture switching isn't really all that bad on performance.

Or finally, a combination of those last two things - do anything that isn't semi-transparent with full batching and using Z-buffers, ignoring rule A, then just don't worry about rule B for semi-transparent things because maybe there won't be all that many of them, and obviously you can't reliably do anything to work around that other than regenerating atlases.

Orzo
Sep 3, 2004

IT! IT is confusing! Say your goddamn pronouns!
Thanks, those are all good ideas. For my particular requirements, the first one (dynamically create an atlas) is something I've considered, but it wouldn't really be a complete solution since I have a lot of dynamic (scripted) creation of entities, which would be very difficult to predict at run-time. For example, on entering a level it would be fairly easy to generate an atlas for the pre-built tiles and entities that are there, but behaivors that drive those entities could easily page a texture in that wasn't part of that set.

I guess I could dynamically re-create the atlas every time one of these textures is paged in, but I'm little apprehensive about marrying myself to that approach in case it causes memory issues, plus it's fairly complex of a solution when compared with the other proposals you've given.

Yodzilla
Apr 29, 2005

Now who looks even dumber?

Beef Witch
So is there some weird difference between running Unity in Windows and OSX? I've been working on my Futile project in Windows just fine but as soon as I tried to compile it in OSX it chokes on this in FScreen.cs

code:
#if UNITY_IPHONE || UNITY_ANDROID
TouchScreenKeyboard.autorotateToLandscapeLeft = false;
TouchScreenKeyboard.autorotateToLandscapeRight = false;
TouchScreenKeyboard.autorotateToPortrait = false;
TouchScreenKeyboard.autorotateToPortraitUpsideDown = false;
I found this post saying it was undocumented deprecated code but his replacement

code:
Screen.autorotateToPortrait = autoRotateKeyboardPortrait;
Screen.autorotateToPortraitUpsideDown = autoRotateKeyboardPortraitUpsideDown;
Screen.autorotateToLandscapeLeft = autoRotateKeyboardLandscapeLeft;
Screen.autorotateToLandscapeRight = autoRotateKeyboardLandscapeRight;
doesn't compile either? I'm guessing that the OSX version of Unity is hitting the UNITY_IPHONE bit which is kind of weird but what is the correct way to do...whatever is supposed to be here?

devilmouse
Mar 26, 2004

It's just like real life.
Not knowing any of the Futile codebase and only looking at the Unity header files, this isn't an OSX v Windows issue. It shouldn't compile on either (in 4.1 at least). TouchScreenKeyboard doesn't contain these autorotate members. Screen however does.

If you changed FScreen.cs:51-54 to :
code:
Screen.autorotateToPortrait = false; 
Screen.autorotateToPortraitUpsideDown = false;
Screen.autorotateToLandscapeLeft = false;
Screen.autorotateToLandscapeRight = false;
It'll at least compile... whether it works or not, I can't say.

Yodzilla
Apr 29, 2005

Now who looks even dumber?

Beef Witch
Thanks. Yeah my goals for tonight were 1) learn how to test and debug Unity on iOS devices and 2) learn how to manipulate and read device orientation. The latter got me a little mixed up but I think I've got a handle on it now...for the most part.

Yodzilla fucked around with this message at 04:07 on Apr 10, 2013

Orzo
Sep 3, 2004

IT! IT is confusing! Say your goddamn pronouns!
Question about 2D graphics stuff, blending modes. My particular implementation is DirectX, but I'm guessing this applies to OpenGL.

I am trying to implement faux "lighting" with the following layer setup, hopefully what I want is possible to achieve with just sprites and the appropriate blending modes. Theoretical top-to-bottom layers:

1. A giant dark rectangle covering the entire view, represents the ambient darkness. Full darkness would be a giant black sprite.
2. A white gradient sprite which represents a 'light'. The idea is to use this sprite to 'subtract darkness' from the sprite on layer 1.
3. Everything in layer 3 and below represents normal game layers, and can be a mixture of regular transparency, additive blending, etc.

Is this possible? I know I can modify the BlendOperation in DirectX for layer 2, but what would the SourceBlend and DestinationBlend be for layers 1 and 2?

Adbot
ADBOT LOVES YOU

Shalinor
Jun 10, 2002

Can I buy you a rootbeer?

Orzo posted:

Question about 2D graphics stuff, blending modes. My particular implementation is DirectX, but I'm guessing this applies to OpenGL.

I am trying to implement faux "lighting" with the following layer setup, hopefully what I want is possible to achieve with just sprites and the appropriate blending modes. Theoretical top-to-bottom layers:

1. A giant dark rectangle covering the entire view, represents the ambient darkness. Full darkness would be a giant black sprite.
2. A white gradient sprite which represents a 'light'. The idea is to use this sprite to 'subtract darkness' from the sprite on layer 1.
3. Everything in layer 3 and below represents normal game layers, and can be a mixture of regular transparency, additive blending, etc.

Is this possible? I know I can modify the BlendOperation in DirectX for layer 2, but what would the SourceBlend and DestinationBlend be for layers 1 and 2?
Render #1 and #2 to an off-screen buffer. #1 is the base layer, write / no z / no alpha. #2 is blended over the top of that additively. Then take the composite buffer and render it over the regular scene buffer multiplicatively. Make sure that the composite buffer is double-buffered - which would lag your lighting a single frame, but keep you from trashing perf with a dependent render.

You can even vary the off-screen buffer size to optimize performance, do a high pass blur over it to fake some kind of bloom, etc.

EDIT: You could probably do it without the off-screen buffer with some stencil trickery, but it's 11pm and my brain is overcooked porridge. The buffer approach is straightforward and should serve you just fine, though.

Shalinor fucked around with this message at 06:12 on Apr 11, 2013

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply