|
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. 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 |
# ? Apr 6, 2013 22:32 |
|
|
# ? May 26, 2024 02:26 |
|
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!
|
# ? Apr 6, 2013 22:42 |
|
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. 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?
|
# ? Apr 6, 2013 22:47 |
|
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?
|
# ? Apr 6, 2013 22:50 |
|
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
|
# ? Apr 6, 2013 22:56 |
|
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.
|
# ? Apr 6, 2013 23:13 |
|
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.
|
# ? Apr 6, 2013 23:18 |
|
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
|
# ? Apr 7, 2013 00:58 |
|
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. 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?
|
# ? Apr 7, 2013 01:16 |
|
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 |
# ? Apr 7, 2013 03:48 |
|
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.
|
# ? Apr 7, 2013 05:11 |
|
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. 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.
|
# ? Apr 7, 2013 05:19 |
|
roomforthetuna posted:I've never used it, but two thoughts: 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 |
# ? Apr 7, 2013 05:36 |
|
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? * 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
|
# ? Apr 7, 2013 05:59 |
|
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.
|
# ? Apr 7, 2013 06:49 |
|
Shalinor posted:It would really only be useful for total conversion-style new campaign/story things. Allowing multiple mods to work together is probably much less important, and TCs often springboard off of the interest developed from smaller projects.
|
# ? Apr 7, 2013 06:59 |
|
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
|
# ? Apr 7, 2013 11:56 |
|
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.
|
# ? Apr 7, 2013 19:03 |
|
Thanks for the reply! I've got both RPGs and action games in mind so I guess I'll learn pyglet too.
|
# ? Apr 7, 2013 19:32 |
|
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:
|
# ? Apr 7, 2013 20:57 |
|
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.
|
# ? Apr 8, 2013 02:04 |
|
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:
|
# ? Apr 8, 2013 02:19 |
|
SupSuper posted:If it makes you feel better, those strange stepped hills immediately gave me SimCity 2000 vibes. 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.
|
# ? Apr 8, 2013 03:35 |
|
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: 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.
|
# ? Apr 8, 2013 16:21 |
|
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:
|
# ? Apr 8, 2013 19:00 |
|
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:
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:
Chunderstorm fucked around with this message at 23:09 on Apr 8, 2013 |
# ? Apr 8, 2013 19:57 |
|
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.
|
# ? Apr 8, 2013 20:10 |
|
Orzo posted:2D engine question: 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.
|
# ? Apr 8, 2013 20:19 |
|
OneEightHundred posted:If all of the sprites are in the same atlas, you shouldn't have a problem. 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!
|
# ? Apr 8, 2013 22:31 |
|
How important is requirement B? Are you really running into performance issues rendering sprites?
|
# ? Apr 8, 2013 22:47 |
|
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.
|
# ? Apr 8, 2013 22:50 |
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?
|
|
# ? Apr 8, 2013 22:58 |
|
Manslaughter posted:The problem is that you're rendering thousands of sprites. 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.
|
# ? Apr 8, 2013 23:39 |
|
Orzo posted:2D engine question: 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.
|
# ? Apr 9, 2013 01:09 |
|
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.
|
# ? Apr 9, 2013 01:55 |
|
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.cscode:
code:
|
# ? Apr 10, 2013 00:04 |
|
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:
|
# ? Apr 10, 2013 03:30 |
|
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 |
# ? Apr 10, 2013 03:53 |
|
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?
|
# ? Apr 11, 2013 05:00 |
|
|
# ? May 26, 2024 02:26 |
|
Orzo posted:Question about 2D graphics stuff, blending modes. My particular implementation is DirectX, but I'm guessing this applies to OpenGL. 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 |
# ? Apr 11, 2013 06:08 |