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
AntiPseudonym
Apr 1, 2007
I EAT BABIES

:dukedog:

superh posted:

That looks like it's in the sprite editor, is that what you mean? You can definitely script it. I'm not at my desk right now but, I know I grabbed a plugin for parsing texturepacker sprites and that's doing it, if you need an example.

Yeah, that's pretty much exactly what I'm after. If you could post an example that'd be brilliant!

Adbot
ADBOT LOVES YOU

Joda
Apr 24, 2010

When I'm off, I just like to really let go and have fun, y'know?

Fun Shoe
I managed to implement an alias map that welds together two vertices if they are exactly the same. It's entirely appropriate for the coding horrors thread, and I expect to hate myself whenever I have to revisit it, but at least it works. Still trying to figure out how to adjust for angle.



It can't handle margins of error (since I use a simple hash map,) so the vertices have to be exactly the same, so there are still some artifacts here and there.

I then proceeded to follow wayfinder's advice to fix my quad problem; still not defined but getting there. Video will have to wait.

Thanks a bunch for the help!

Joda fucked around with this message at 03:40 on Mar 28, 2015

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!

Joda posted:

I managed to implement an alias map that welds together two vertices if they are exactly the same. It's entirely appropriate for the coding horrors thread, and I expect to hate myself whenever I have to revisit it, but at least it works. Still trying to figure out how to adjust for angle.



It can't handle margins of error (since I use a simple hash map,) so the vertices have to be exactly the same, so there are still some artifacts here and there.

I then proceeded to follow wayfinder's advice to fix my quad problem; still not defined but getting there. Video will have to wait.

Thanks a bunch for the help!
If you're doing this as a pre-processing step (saving to another file that your game loads rather than reading from some file format that's jacked up) then I'd recommend just doing a simplistic expensive everything-to-everything comparison - it's not so slow as to be a problem at build-time, and means you can super easily do "near" comparisons.

You could also do it reasonably quickly with nested non-hash maps (binary tree kind, like std::map) - that way you can get the nearby points with 3 log n operations. (store as map<float, map<float, multimap<float, actual_point>>>, add a new point like map[z][y].insert(x, actual_point_details), then you can iterate over nearby points by iterating from map.lower_bound(z-max_distance) to map.upper_bound(z+max_distance), nesting that kind of loop three deep.

You probably want to set a similarity threshold for the vertex/face normals - when I wrote something like this in an importer the source data had face normals, so to get smoothed surfaces I went with something like a 30 degree threshold. You then need to take the average of the normals that are going to be sharing a point, that gets you surfaces where the lighting is smoothed. If the normals aren't similar enough to be within the threshold then you don't merge the points, that way you can still get sharp-cornered cubes. (Cubes with the normals pointing diagonally out from the corners look stupid.)

superh
Oct 10, 2007

Touching every treasure

AntiPseudonym posted:

Yeah, that's pretty much exactly what I'm after. If you could post an example that'd be brilliant!

It looks like the relevant code is spread all over the place in my project, but the guts of it are:

Create a List of these SpriteMetaData's, these are basically the rects you want:
http://docs.unity3d.com/ScriptReference/SpriteMetaData.html

Then you take that List and apply it back to the sprite via the texture importer.

code:
TextureImporter texImp = AssetImporter.GetAtPath(path) as TextureImporter;
texImp.spritesheet = sprites.ToArray();
texImp.textureType = TextureImporterType.Sprite;
texImp.spriteImportMode = SpriteImportMode.Multiple;
AssetDatabase.ImportAsset( path, ImportAssetOptions.ForceUpdate );
Actually building the SpriteMetaDatas happens elsewhere but it's fairly straightforward.

Hope that helps!

AntiPseudonym
Apr 1, 2007
I EAT BABIES

:dukedog:

superh posted:

It looks like the relevant code is spread all over the place in my project, but the guts of it are:

Create a List of these SpriteMetaData's, these are basically the rects you want:
http://docs.unity3d.com/ScriptReference/SpriteMetaData.html

Then you take that List and apply it back to the sprite via the texture importer.

code:
TextureImporter texImp = AssetImporter.GetAtPath(path) as TextureImporter;
texImp.spritesheet = sprites.ToArray();
texImp.textureType = TextureImporterType.Sprite;
texImp.spriteImportMode = SpriteImportMode.Multiple;
AssetDatabase.ImportAsset( path, ImportAssetOptions.ForceUpdate );
Actually building the SpriteMetaDatas happens elsewhere but it's fairly straightforward.

Hope that helps!

Ah right, I slightly misread your original post and thought you said LIKE the sprite editor, whoops. Sorry! :( Still, good information to know, thanks!

I've mosty finished what I was working on; a custom bitmap font editor dialog so you don't have to manually enter the UV and vert coordinates. Still working out some kinks with setting baselines for each character, which is difficult because I want it to work with all the current information in the Font object (So in theory people could just use their old custom fonts with this tool directly), but I don't seem to have a good spot to store the baseline information which sort of sucks. :(

America Inc.
Nov 22, 2013

I plan to live forever, of course, but barring that I'd settle for a couple thousand years. Even 500 would be pretty nice.
What's it like to work as a playtester?

AntiPseudonym
Apr 1, 2007
I EAT BABIES

:dukedog:

LookingGodIntheEye posted:

What's it like to work as a playtester?

Probably better off asking in the Game Jobs Megathread, but... it's tough. Long hours, low pay, constant fear of being laid off because you're essentially disposable unless you manage to make it to a lead. You'll be playing games a lot of the day, but they'll be lovely, broken, unfinished games that you'll have to play for hours on end, constantly following incredibly specific instructions to try and reproduce incredibly strange bugs.

All that said though, if you like breaking games and don't mind doing a fair bit of paperwork, it can be a good job for some people depending on where you work. Publisher QA is one of the ones I've heard the most horror stories about (But never worked directly with), but internal developer QA can range from bad to fantastic. The last place I worked at we had a really good and fluid relationship between the QA guys and the dev team, and the place before that the QA department seemed to have a grand old time upstairs in their own little room. Both jobs also had room for QA to make their way onto the dev team - as artists, designers, programmers and even producers. The downside is that in developer QA you're probably going to have even less games that you could potentially be testing, and you'll probably be testing the same game for years at a stretch, at least in the AAA space. Mobile and indie studios tend to have more games going at once.

So yeah, if you're interested in it to get paid for playing games you're probably going to be sorely disappointed with testing as a job. Although if you have aspirations of using it as a stepping stone into the industry, and don't mind the actual work of methodically playing the same tiny fraction of a level over and over again to reproduce a rare bug that happens 1/100 times, it can be a fun job if you work for the right studio.

America Inc.
Nov 22, 2013

I plan to live forever, of course, but barring that I'd settle for a couple thousand years. Even 500 would be pretty nice.

AntiPseudonym posted:

Although if you have aspirations of using it as a stepping stone into the industry, and don't mind the actual work of methodically playing the same tiny fraction of a level over and over again to reproduce a rare bug that happens 1/100 times, it can be a fun job if you work for the right studio.
This is what I'm looking for. I'm just beginning my programming career at this point and I'm open to exploring multiple fields.

AntiPseudonym
Apr 1, 2007
I EAT BABIES

:dukedog:

LookingGodIntheEye posted:

This is what I'm looking for. I'm just beginning my programming career at this point and I'm open to exploring multiple fields.

Yep, in that case just do some research on the companies you apply for, a lot have a habit of laying off people with no notice as soon as a project finishes (Or even before in some cases), and some have really terrible internal cultures.

Although just as a warning, moving up from QA to dev can take years if it even happens at all, and you might be better off just making your own games in your spare time. Having finished, released games (Even if they're just simple puzzle games or endless runners) is something that will really help when applying for jobs.

Paniolo
Oct 9, 2007

Heads will roll.
It's generally easier to break into the industry from a related field (such as non-games programming) than it is to transition from test to a developer role. It's not that it's uncommon for people to make that transition, it's just that of the huge number of people trying, very few will and it usually takes years. There are two major obstacles: first, the skillset overlap between QA and designer or programmer jobs is minimal, so you're not going to be taught the skills you need to move into those positions. And second, because a large number of people in test would rather be in developer roles and are using QA to get their foot in the door, many companies have specific policies that make this harder to do, such as minimum amounts of time you need to be at the company before you could put in an internal application to a different org.

QA will give you a foot in the door and opportunities that wouldn't exist otherwise. But understand that as a tester, becoming a designer or programmer or producer is not on your career path, and that the main advantage consists of access (to tools, documentation, and people) who can help you develop the skills needed before you can make a career change. Actually developing those skills is entirely on you.

Paniolo fucked around with this message at 08:19 on Mar 29, 2015

OneEightHundred
Feb 28, 2008

Soon, we will be unstoppable!

LookingGodIntheEye posted:

This is what I'm looking for. I'm just beginning my programming career at this point and I'm open to exploring multiple fields.
Getting a position as a programmer is almost entirely about how good of a programmer you are (or more accurately, how good of a programmer that you can demonstrate that you are.) Doing QA stuff isn't really going to help you with that. For that matter, doing programming work for a non-game company of pretty much any sort is going to be vastly more useful than doing QA at a game company.

Police Automaton
Mar 17, 2009
"You are standing in a thread. Someone has made an insightful post."
LOOK AT insightful post
"It's a pretty good post."
HATE post
"I don't understand"
SHIT ON post
"You shit on the post. Why."
I don't really know where else to ask the question I have so I am just going to ask here.

I'm from an electronics/programming background (lately more electronics than programming because I switched careers from being self-employed) but like every aging nerd I always had that dream of writing my own vidya. Over the years I always had a brainchild which once started off in the ancient days of the old Commodore Amiga and sort of progressed with platforms, programming languages and my own knowledge. The latest incarnation I shaped in C# (not utilizing any 3rd party engine because they didn't exist then, but just pretty much from scratch utilizing OpenGL when everyone still said C# will never be a thing for video games) just writing a very basic 2D engine and just exploring a few ideas and never tying it into a coherent package. (for example writing a multithreaded pathfinding engine, or a fractal landscape generator)

I would like to finally make the push and realize my idea into a coherent game for others to enjoy. I just really notice again and again I do not really know where to start organizationally and feel a bit overwhelmed regarding the options. Designing a game is very different from everything else I have ever done before, and nowadays with all that steam stuff 3rd part engines everyone seems to employ and etc. I am a bit overwhelmed what the best path to take would be to take idea and code to something that people actually can end up playing. I don't want to turn into the dwarf-fortress guy. If anyone has a primer that outlines organizational strategies of game development I would be much obliged. I don't plan on getting rich (or even quitting my current job for that matter) but I would like to turn my idea into something more "real" in the next few years and into something other people could also play. I hope this wasn't too outlandish a question and makes some sense.

Centripetal Horse
Nov 22, 2009

Fuck money, get GBS

This could have bought you a half a tank of gas, lmfao -
Love, gromdul

Police Automaton posted:

I don't really know where else to ask the question I have so I am just going to ask here.

I'm from an electronics/programming background (lately more electronics than programming because I switched careers from being self-employed) but like every aging nerd I always had that dream of writing my own vidya. Over the years I always had a brainchild which once started off in the ancient days of the old Commodore Amiga and sort of progressed with platforms, programming languages and my own knowledge. The latest incarnation I shaped in C# (not utilizing any 3rd party engine because they didn't exist then, but just pretty much from scratch utilizing OpenGL when everyone still said C# will never be a thing for video games) just writing a very basic 2D engine and just exploring a few ideas and never tying it into a coherent package. (for example writing a multithreaded pathfinding engine, or a fractal landscape generator)

I would like to finally make the push and realize my idea into a coherent game for others to enjoy. I just really notice again and again I do not really know where to start organizationally and feel a bit overwhelmed regarding the options. Designing a game is very different from everything else I have ever done before, and nowadays with all that steam stuff 3rd part engines everyone seems to employ and etc. I am a bit overwhelmed what the best path to take would be to take idea and code to something that people actually can end up playing. I don't want to turn into the dwarf-fortress guy. If anyone has a primer that outlines organizational strategies of game development I would be much obliged. I don't plan on getting rich (or even quitting my current job for that matter) but I would like to turn my idea into something more "real" in the next few years and into something other people could also play. I hope this wasn't too outlandish a question and makes some sense.

Program a game. Seriously, make anything, as long as you complete it. There really is no substitute for experience. Writing a game from scratch will lead you into a lot of roadblocks, and expose a lot of questions and challenges that I think will help give you a starting reference for your larger project(s). You can make an effort to include things you expect to be in your big game, but even if you don't, you will learn a lot.

If you're not familiar with Handmade Hero, definitely have a look: HandmadeHero.org. Casey Muratori is programming a game, from scratch, live on the internet, using no third-party libraries. The forums there are becoming pretty active, and some fairly well-known programmers, from game-industry to language-designers, participate.

Start haunting the Indie Gamer forums and other message boards dedicated to the industry. Like most things, there is a lot of lovely advice and information out there. Some people will say that's what I'm giving you, right now. Do your best to farm the bits that apply to you and your goals.

I am sure other people will be along with more specific advice, shortly. Try not to get too hung up on how other people do things, though. In my experience, the process is so unique to the individual that, no matter what people tell you, you're going to have to discover about 75% of it for yourself.

ShinAli
May 2, 2003

The Kid better watch his step.

LookingGodIntheEye posted:

This is what I'm looking for. I'm just beginning my programming career at this point and I'm open to exploring multiple fields.

Working on your own game projects is infinitely better than trying to break through as QA. You might have a slightly easier time to get into the studio you're QA'ing at, but connections as a QA guy will not make up for a lack of skills when you're compared to other candidates.

Pentecoastal Elites
Feb 27, 2007

I have a perspective projection camera I want to track a point with as it moves around a rectangular stage. The stage is 2D (along the X/Y axis) and the point (the centroid of player positions) has a constant Z.
However, I want to prevent the camera’s view from extending past the level bounds. This would be trivial with an orthographic projection, but I’m having trouble with a perspective camera (especially because it can pivot along its Y axis, in certain situations)

The obvious brute-force solution would be to raycast and stop the camera from moving when the rays hit one of the boundaries (or from one of the boundaries?). This would be at least four rays a frame, every frame, and seems way too expensive.
I don’t necessarily want the camera to move too much, or too quickly, so I was going to have it gently lerp towards the point. I might be able to get away with raycasting to/from one of the four bounds every few frames, then adjusting the centroid (and thus the camera path) based on that. This would probably work, but it might make the camera feel too loose, and might be too expensive anyway
The other approach I thought of might be better, but I’m not sure how to implement it yet, but it would be defining a bounding box for the stage, then calculating the camera frustum slice at player-z, and making sure none of those points intersect. I should only have to recalculate if camera changes rotation (and even then I’d only have to determine the frustum at the end rotation).

Is there an easier way to do this? Or a best practice for keeping the viewport in within a bounds?

Unity, if it helps.

Police Automaton
Mar 17, 2009
"You are standing in a thread. Someone has made an insightful post."
LOOK AT insightful post
"It's a pretty good post."
HATE post
"I don't understand"
SHIT ON post
"You shit on the post. Why."

Centripetal Horse posted:

Program a game. Seriously, make anything, as long as you complete it. There really is no substitute for experience. Writing a game from scratch will lead you into a lot of roadblocks, and expose a lot of questions and challenges that I think will help give you a starting reference for your larger project(s). You can make an effort to include things you expect to be in your big game, but even if you don't, you will learn a lot.

If you're not familiar with Handmade Hero, definitely have a look: HandmadeHero.org. Casey Muratori is programming a game, from scratch, live on the internet, using no third-party libraries. The forums there are becoming pretty active, and some fairly well-known programmers, from game-industry to language-designers, participate.

Start haunting the Indie Gamer forums and other message boards dedicated to the industry. Like most things, there is a lot of lovely advice and information out there. Some people will say that's what I'm giving you, right now. Do your best to farm the bits that apply to you and your goals.

I am sure other people will be along with more specific advice, shortly. Try not to get too hung up on how other people do things, though. In my experience, the process is so unique to the individual that, no matter what people tell you, you're going to have to discover about 75% of it for yourself.

Basically, this was all I really wanted to hear I think. I followed your links and read a little here and there and am surprised how many people approach this field without even really knowing programming basics. That explains the popularity of things like Unity for me a bit. I guess my knowledge about these things (scene/market/however you want to call it) is a bit outdated.

I for myself see no use in using any 3rd party engine as I dusted off my old source with all the interface classes and it still compiles fine (without changes!) and works both in Linux and Windows, and it does all I need for now. I remember putting a lot of effort into only updating screen regions that had changes (my computer really was that slow back then) and this nets me five-digit framerates now on my current computer which cracked me up. I do think I should learn how to get better organized as I tend to get lost in details and then never manage to get anywhere. But that's not really a game-development specific thing to learn. It's a shame that I can't even do the most basic pixel art to save my life.

Police Automaton fucked around with this message at 14:44 on Mar 31, 2015

Yodzilla
Apr 29, 2005

Now who looks even dumber?

Beef Witch

I could be really, incredibly wrong but isn't four rays a frame pretty trivial performance wise? I'm working on a 2D action game that uses the prime31 CharacterController2D and it uses a bunch of rays to detect collision every frame and it runs just fine with multiple players at once. In bigger games aren't raycasts used all over the goddamn place for checking any number of things?

Centripetal Horse
Nov 22, 2009

Fuck money, get GBS

This could have bought you a half a tank of gas, lmfao -
Love, gromdul

Police Automaton posted:

Basically, this was all I really wanted to hear I think.

I hope it was helpful or encouraging in some way. I don't want to be too maudlin, but independent games are still magical to me. They tend to have more personality, and they cover subject matter and play-styles that you don't see in big-studio projects. The line is blurring as independent games become "big" games, but I think that blurred middle ground is still fertile. I feel that to lose the spark that comes from individuals chasing their visions would be a very sad thing. My answer is always, "Do it," when someone seems to be on the fence about developing some idea they've been sitting on.

Police Automaton posted:

I for myself see no use in using any 3rd party engine as I dusted off my old source with all the interface classes and it still compiles fine (without changes!) and works both in Linux and Windows, and it does all I need for now. I remember putting a lot of effort into only updating screen regions that had changes (my computer really was that slow back then) and this nets me five-digit framerates now on my current computer which cracked me up. I do think I should learn how to get better organized as I tend to get lost in details and then never manage to get anywhere. But that's not really a game-development specific thing to learn. It's a shame that I can't even do the most basic pixel art to save my life.

That's cool. I wouldn't say I see no point in third-party libraries, but they're certainly optional in most cases. The only thing I can say on the subject of getting bogged down in details is: don't. I know that's not terribly helpful, but if you're finding that the details stop you from getting your projects done, then just skip them. Fly by the seat of your pants. Losing time refactoring code to accommodate changes is better than never producing any code in the first place.

I, too, am a miserable, miserable, miserable artist. Pixel art is, well, an art. The good stuff is just amazing to me. I can hardly believe the beauty some artists can coax out of a limited palette and low resolution. I have always been in awe of artists. The main reason I keep letting people stab ink into my skin is that the process seems almost supernatural to me. I'm blown away that I can walk around with art on my body, which I know I could never reproduce in a million years of trying.

Bondematt
Jan 26, 2007

Not too stupid

Yodzilla posted:

I could be really, incredibly wrong but isn't four rays a frame pretty trivial performance wise? I'm working on a 2D action game that uses the prime31 CharacterController2D and it uses a bunch of rays to detect collision every frame and it runs just fine with multiple players at once. In bigger games aren't raycasts used all over the goddamn place for checking any number of things?

Yeah, 4 raycasts an Update is nothing. On PC I'm running a couple hundred just to make my mesh for a stencil buffer shader every Update.

Onion Knight posted:

I have a perspective projection camera I want to track a point with as it moves around a rectangular stage. The stage is 2D (along the X/Y axis) and the point (the centroid of player positions) has a constant Z.
However, I want to prevent the camera’s view from extending past the level bounds. This would be trivial with an orthographic projection, but I’m having trouble with a perspective camera (especially because it can pivot along its Y axis, in certain situations)

The obvious brute-force solution would be to raycast and stop the camera from moving when the rays hit one of the boundaries (or from one of the boundaries?). This would be at least four rays a frame, every frame, and seems way too expensive.
I don’t necessarily want the camera to move too much, or too quickly, so I was going to have it gently lerp towards the point. I might be able to get away with raycasting to/from one of the four bounds every few frames, then adjusting the centroid (and thus the camera path) based on that. This would probably work, but it might make the camera feel too loose, and might be too expensive anyway
The other approach I thought of might be better, but I’m not sure how to implement it yet, but it would be defining a bounding box for the stage, then calculating the camera frustum slice at player-z, and making sure none of those points intersect. I should only have to recalculate if camera changes rotation (and even then I’d only have to determine the frustum at the end rotation).

Is there an easier way to do this? Or a best practice for keeping the viewport in within a bounds?

Unity, if it helps.

If you know the Bounds X and Y you want the camera limited to; couldn't you just take the Camera's current position and then stop it when it hits whatever X/Y you want it to stop at?

ErIog
Jul 11, 2001

:nsacloud:

Bondematt posted:

Yeah, 4 raycasts an Update is nothing. On PC I'm running a couple hundred just to make my mesh for a stencil buffer shader every Update.


If you know the Bounds X and Y you want the camera limited to; couldn't you just take the Camera's current position and then stop it when it hits whatever X/Y you want it to stop at?

That wouldn't work if his levels had vertical walls that could impact the camera.

Pentecoastal Elites
Feb 27, 2007

Yodzilla posted:

I could be really, incredibly wrong but isn't four rays a frame pretty trivial performance wise? I'm working on a 2D action game that uses the prime31 CharacterController2D and it uses a bunch of rays to detect collision every frame and it runs just fine with multiple players at once. In bigger games aren't raycasts used all over the goddamn place for checking any number of things?

Bondematt posted:

Yeah, 4 raycasts an Update is nothing. On PC I'm running a couple hundred just to make my mesh for a stencil buffer shader every Update.

Oh, huh. I've only ever heard "raycasts are expensive" with no qualification so I've been kind of gun shy about using them. I think in that case I'll just try the brute force approach, and if that doesn't work (or I get a big performance hit) maybe then try to figure out frustum math. Thanks for the help.

quote:

If you know the Bounds X and Y you want the camera limited to; couldn't you just take the Camera's current position and then stop it when it hits whatever X/Y you want it to stop at?

If the camera was orthographic, sure. I mean, I could still do this, but I want to maximize the gameworld on-screen. If I sit the camera, physically, on the bottom of the level I still have half the screen filled with floor.

wayfinder
Jul 7, 2003
You can do literally thousands of raycasts per frame on a modern system without much of a performance hit. Hundreds in a web app.

Zaphod42
Sep 13, 2012

If there's anything more important than my ego around, I want it caught and shot now.

Onion Knight posted:

Oh, huh. I've only ever heard "raycasts are expensive" with no qualification so I've been kind of gun shy about using them. I think in that case I'll just try the brute force approach, and if that doesn't work (or I get a big performance hit) maybe then try to figure out frustum math. Thanks for the help.


If the camera was orthographic, sure. I mean, I could still do this, but I want to maximize the gameworld on-screen. If I sit the camera, physically, on the bottom of the level I still have half the screen filled with floor.

Raycasts are expensive, IF you're doing a ray cast or several ray casts per pixel in a 1920x1080 array per frame. Throwing 4 rays at the screen is negligible.

Yodzilla
Apr 29, 2005

Now who looks even dumber?

Beef Witch
Hey everyone! Our newest title Stick & Move is out now for Windows, OSX, and Linux for only $1.99! http://ghost-crab-games.itch.io/stick-and-move



It's sort of early access in that it's a game jam entry in which the goal is to release a game and actually make some money on it. People have been loving it so far though and this version includes one game mode, five color schemes, and a kicksass synthwave soundtrack. In the future we'll be adding more of everything including a challenge mode. If it tickles your fancy please give it a shot, tell your friends, and give us some feedback!

https://www.youtube.com/watch?v=Q1ShFwoNtUs

Nition
Feb 25, 2006

You really want to know?

Onion Knight posted:

I have a perspective projection camera I want to track a point with as it moves around a rectangular stage. The stage is 2D (along the X/Y axis) and the point (the centroid of player positions) has a constant Z.
However, I want to prevent the camera’s view from extending past the level bounds. This would be trivial with an orthographic projection, but I’m having trouble with a perspective camera (especially because it can pivot along its Y axis, in certain situations)

The obvious brute-force solution would be to raycast and stop the camera from moving when the rays hit one of the boundaries (or from one of the boundaries?). This would be at least four rays a frame, every frame, and seems way too expensive.
I don’t necessarily want the camera to move too much, or too quickly, so I was going to have it gently lerp towards the point. I might be able to get away with raycasting to/from one of the four bounds every few frames, then adjusting the centroid (and thus the camera path) based on that. This would probably work, but it might make the camera feel too loose, and might be too expensive anyway
The other approach I thought of might be better, but I’m not sure how to implement it yet, but it would be defining a bounding box for the stage, then calculating the camera frustum slice at player-z, and making sure none of those points intersect. I should only have to recalculate if camera changes rotation (and even then I’d only have to determine the frustum at the end rotation).

Is there an easier way to do this? Or a best practice for keeping the viewport in within a bounds?

Unity, if it helps.

I think this is what you want: http://www.gamasutra.com/blogs/EricUndersander/20131001/201382/Accurate_Collision_Zoom_for_Cameras.php

Pentecoastal Elites
Feb 27, 2007

That's a good idea (and I've squirreled it away for later, so thank you!) but I ended up going a completely different route.
My raycasting solution started getting way too complicated -- I was sticking all the code on a lerping camera and then basing all my calculations on its transforms (dumb) so I had all of this decay metering nonsense and it still wasn't looking good.

Instead I just added another gameobject with a box collider to my hierarchy that only collides with the level boundaries. It keeps itself centered on the player positions centroid, and encapsulates each player's position. Because all player z-positions are fixed at zero, the collider's depth is a just a function of it's length and width.

The camera, now, just tracks this object and lerps after the center of its camera-facing normal.

It's pretty much perfect. I have the Smash Brothers camera, and it's exactly what I wanted.

:toot:~a programming success~:toot:

ShichiNoBushi
Sep 16, 2010
To get my bachelor's degree, I did a final project writing a game design document for mouse-based puzzle platformer. For a while I had intended to create a prototype for the game so I can potentially market it. After initially making it in Game Maker, I decided to start working on it in Unity 2D, but I hit what is probably the stupidest problem. I can't seem to get the environmental objects to have repeating textures. What I did was make Box Collider 2Ds with Sprite Renderers, but as I try to adjust their size so, I don't just make a bunch of objects instead of a few that were resized, the images stretches. What I want to do is have the texture stay the same size and instead tile. I also tried changing the sprites into textures, but apparently Sprite Renderers don't accept them. If anyone has any advice accomplishing this, please tell me.

If anyone is interested in the game I'm trying to make itself here is the Google doc for it. I would appreciate any constructive criticism anyone can provide for that.

ErIog
Jul 11, 2001

:nsacloud:
The solution is not to use SpriteRenderer for something like that. It seems intuitive that you should, but getting it to work the way you want it with a SpriteRenderer is going to involve you writing graphics code to make it work.

The standard answer to this question in Unity is to use textured Quads with AlphaBlended shaders that use Textures set to Wrap Mode: Repeat. You might have to futz with some values to get Unity to map the pixels to world scale properly, but once you do that it works fine.

http://answers.unity3d.com/questions/587007/im-trying-to-create-a-tiled-sprite-what-am-i-doing.html

Purple Prince
Aug 20, 2011

What's a good program / library for making a small interactive project to accompany a piece of research on how games use interactivity to convey narrative? At the moment I'm considering using the Flixel library to teach myself Actionscript 3 at the same time as creating the project, but I'm concerned that my lack of experience with the libraries etc. will slow me down. I'd also be interested in learning Unity or Unreal 2D with future projects in mind.

Some relevant factors for the project:
- 10-15 weeks; developed at the same time as research.
- Producing a short piece of gameplay to demonstrate the concepts in the research.
- I'd also be interested in learning a new language / toolset which I can reuse in the future for 2d projects.
- I'd describe myself as a low intermediate in C++; I can solve most problems and optimise code alright, and I'm starting to look into overall program structure and patterns. Toolsets which use C++ but make development much faster than with 'raw' code would be nice (UE4?)

The Atomic Man-Boy
Jul 23, 2007

I'm just getting into building my own game.

I count myself a decent programmer, and know a fair bit of unity. Its going to be an interesting voyage. Sadly, I know nothing making art assets.

I'm trying to make a hack'n slash type of game. But I don't know about the modeling/animation/rigging/skinning pipeline. I want to whip up a skeleton body in Blender that I can use as a placeholder for development, which a real artist can expand upon later. Here's the requirements:

1) A human shaped skeleton that can be used for both male and female characters meshes.
2) Can be used for all animations, i.e. "sword slash 1", "walk", "run", "die" etc.
3) Can be re-skinned programmatically with a few different faces.
4) Has a number of sockets that I can add armor/clothes when I have an actual artist.

Unfortunately, as I said, I don't know anything about the asset creation pipeline. So I'm not sure how to go about this. I need to know how to build and animate a skeleton, and use a placeholder that wont be an impediment to my future artists and wont conflict with my unity project when I replace it with skinned/clothed models. Any advice on how to do that is greatly appreciated.

floofyscorp
Feb 12, 2007

The Atomic Man-Boy posted:

I'm just getting into building my own game.

I count myself a decent programmer, and know a fair bit of unity. Its going to be an interesting voyage. Sadly, I know nothing making art assets.

I'm trying to make a hack'n slash type of game. But I don't know about the modeling/animation/rigging/skinning pipeline. I want to whip up a skeleton body in Blender that I can use as a placeholder for development, which a real artist can expand upon later. Here's the requirements:

1) A human shaped skeleton that can be used for both male and female characters meshes.
2) Can be used for all animations, i.e. "sword slash 1", "walk", "run", "die" etc.
3) Can be re-skinned programmatically with a few different faces.
4) Has a number of sockets that I can add armor/clothes when I have an actual artist.

Unfortunately, as I said, I don't know anything about the asset creation pipeline. So I'm not sure how to go about this. I need to know how to build and animate a skeleton, and use a placeholder that wont be an impediment to my future artists and wont conflict with my unity project when I replace it with skinned/clothed models. Any advice on how to do that is greatly appreciated.

There are lots of character models and animation packs on the Asset Store that you can use for placeholders, or you could try something like MakeHuman to make a more customised character model. With the ubiquity of Mecanim it's not terribly hard to find bipedal animations that you can use on any relatively standard human-shaped rig, but if you're thinking about a less than standard-shaped character you'll likely have to make everything for it from scratch. Personally I'd feel that creating and animating a skeleton first, and retrofitting a character model later, is a bit of a backwards workflow - normally I'd make the mesh first, then create a skeleton that fits it and animations that work with that etc. If you're going for standard human proportions though, I guess it's not necessarily a big deal. Things like having an allowance for different faces and armour etc are not something I'd worry about at the skeletal level; that'd be all in the mesh.

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!

floofyscorp posted:

There are lots of character models and animation packs on the Asset Store that you can use for placeholders, or you could try something like MakeHuman to make a more customised character model. With the ubiquity of Mecanim it's not terribly hard to find bipedal animations that you can use on any relatively standard human-shaped rig, but if you're thinking about a less than standard-shaped character you'll likely have to make everything for it from scratch. Personally I'd feel that creating and animating a skeleton first, and retrofitting a character model later, is a bit of a backwards workflow - normally I'd make the mesh first, then create a skeleton that fits it and animations that work with that etc. If you're going for standard human proportions though, I guess it's not necessarily a big deal. Things like having an allowance for different faces and armour etc are not something I'd worry about at the skeletal level; that'd be all in the mesh.
It's not like you're locked into using your programmer art skeleton - you can switch that out later too. I think the idea is to start with programmer art rather than trying to learn to make meshes before you've even got a game to put them in, which I have to say is an excellent idea.
Using free asset store garbage as your placeholder art is probably the best idea. I've previously just made a kind of humanoid blob-monster in Blender (just an oval blob of white material around each bone of the skeleton) when the skeleton movements were to be an important part of the game rather than being purely for visuals.

Explosive Tampons
Jul 9, 2014

Your days are gone!!!
So I'm dicking around with freeglut as part of my university's computer graphics classes. I'm trying to program a 2D vector based game in the style of Vectrex games in C++ and I'm doing fine for now, but I have two important questions (keep in mind I consider myself a beginner in C++):

1- How do I structure my program in a decent way? Currently I have 4 custom functions (glutDisplay, glutReshape, glutPassiveMotion, glutKeyboard) and a entry point function, and a class for GL_LINE_LOOP 2D objects. So far so good but in this model I need to declare my objects as global variables because I need to reference them inside the functions, and where else would I declare them? How will I manage the gamestate later with this mess?
My idea was to create a Game class and stick everything there, create an instance as a global object (or maybe static class? I need to review OOP programming concepts) and just place functions like game.Draw(), game.Update() inside the correspondent glut functions. Not sure though.

2- This is for later when my program is somewhat finished: how do I make edges glow (or bloom or whatever) like vector monitors? Please keep in mind I don't know much about computer graphics at this point.

Here's the source code for reference: http://pastebin.com/FK3HMxbs, thanks :)

PS: this is more of a generic programming question so if this thread isn't the most appropriate one please point me to the right thread.

Bob Morales
Aug 18, 2006


Just wear the fucking mask, Bob

I don't care how many people I probably infected with COVID-19 while refusing to wear a mask, my comfort is far more important than the health and safety of everyone around me!

Japanese Phone Box posted:

So I'm dicking around with freeglut as part of my university's computer graphics classes. I'm trying to program a 2D vector based game in the style of Vectrex games in C++ and I'm doing fine for now, but I have two important questions (keep in mind I consider myself a beginner in C++):

1- How do I structure my program in a decent way?

You can read Game Programming Patterns for free online - http://gameprogrammingpatterns.com/contents.html

Valtis
Sep 21, 2009
I've been implementing a script virtual machine for a university game engine course. I'm using a simple game engine me and few others created for different course as a base for the development. This engine has no scripting support at all as all game logic was hardcoded in a hurry as we ran out of time. I have been slowly moving game logic related stuff into scripts, and for example, invulnerability after taking damage is now completely implemented as a script.



Unfortunately as this is a solo project, I don't have enough time to implement an actual compiler for the scripts. Instead I'm using what amounts to an assembler. The scripts need to be written in almost raw bytecode, the assembler merely takes care of some of the more tedious details like calculating offsets for jumps.



I'm nevertheless pretty happy how it's turning out. The virtual machine has a managed heap for things like strings (which are really char arrays) and a copying garbage collector based on Cheney's algorithm. I can also register arbitrary C++ functions with the virtual machine and then call them from scripts.

ShichiNoBushi
Sep 16, 2010

ErIog posted:

The solution is not to use SpriteRenderer for something like that. It seems intuitive that you should, but getting it to work the way you want it with a SpriteRenderer is going to involve you writing graphics code to make it work.

The standard answer to this question in Unity is to use textured Quads with AlphaBlended shaders that use Textures set to Wrap Mode: Repeat. You might have to futz with some values to get Unity to map the pixels to world scale properly, but once you do that it works fine.

http://answers.unity3d.com/questions/587007/im-trying-to-create-a-tiled-sprite-what-am-i-doing.html

Thanks, your answer helped... sort of. Though now if I want to make multiple distinct objects to create the environment, I need to make a new Material with it's own X-Y Tiling ratio based on the size of the object I'm creating.

If there's a solution that allows me to apply the same Texture or Material to multiple objects with different sizes, I would like to know since that would make things a lot simpler both for me and the game. In the meantime, I at least posted an idea in Unity's feedback in hopes they will eventually implement a more convenient feature for creating 2D games like this.

ErIog
Jul 11, 2001

:nsacloud:

ShichiNoBushi posted:

Thanks, your answer helped... sort of. Though now if I want to make multiple distinct objects to create the environment, I need to make a new Material with it's own X-Y Tiling ratio based on the size of the object I'm creating.

You should only need to make a material for each sprite texture. I didn't have problems with multiple sizes when I used that solution. Things just tiled the texture as much as they could along the length/height of the object.

Explosive Tampons
Jul 9, 2014

Your days are gone!!!

Bob Morales posted:

You can read Game Programming Patterns for free online - http://gameprogrammingpatterns.com/contents.html

Awesome. Just what I needed, thanks Bob Morales. I figured out the structuring for my game but unfortunately glut is based on their own main loop with callbacks for game related events, and I can't figure out how to register references to object methods instead of using plain old functions, so my code is not "great" yet, but passable.

Still looking for how to do the glowing effect on my objects' edges. I don't want to learn shaders (for the moment)...

ShichiNoBushi
Sep 16, 2010

ErIog posted:

You should only need to make a material for each sprite texture. I didn't have problems with multiple sizes when I used that solution. Things just tiled the texture as much as they could along the length/height of the object.

What I noticed trying to get it to work is that if I wanted to make an object 5x1 tiles large, I'd first need to make the material tile 5 X and 1 Y. Then if I adjust the object to the size I wanted, it would be tiled appropriately. Though I only did this with one object, I would expect that If I wanted a different wall 1x5 in size but used the same 5x1 material, the texture would be stretched like before rather than in a 1x5 grid of appropriately scaled sprites. If possible, I would like to use a single material for each texture I use, so if you can more specifically tell me how to accomplish that, I would appreciate it to save on needlessly complicated and resource intensive methods later.

Adbot
ADBOT LOVES YOU

ErIog
Jul 11, 2001

:nsacloud:

ShichiNoBushi posted:

What I noticed trying to get it to work is that if I wanted to make an object 5x1 tiles large, I'd first need to make the material tile 5 X and 1 Y. Then if I adjust the object to the size I wanted, it would be tiled appropriately. Though I only did this with one object, I would expect that If I wanted a different wall 1x5 in size but used the same 5x1 material, the texture would be stretched like before rather than in a 1x5 grid of appropriately scaled sprites. If possible, I would like to use a single material for each texture I use, so if you can more specifically tell me how to accomplish that, I would appreciate it to save on needlessly complicated and resource intensive methods later.

Okay, so I looked at my Unity project to see how I did it. You are correct that you need to set the tiling in the material, but you can configure the tiling differently on different objects the material is attached to. Material is instanced so that a material can have different settings when attached to different game objects. So for example, in my game I have a platform 7 units wide, and so the material settings in the component box look like this:



So you don't need to change the tiling in the material settings itself. You just configure the material on a per-object basis, but you use the same base material. It's the same as how you can attach the same script to multiple objects, but configure the scripts differently based on the variables they contain.

You can change the material tiling programmatically if you do something like this:

code:
Vector2 tilingscale = new Vector2(7, 1);
placedobject.GetComponent<Renderer>().material.SetTextureScale("_MainTex", tilingscale);
So when I instantiate a new platform in my platformer this is part of the code that configures the platform. If you set up your material properly then this tiling scale value is always going to be the same size as the size of your object. So it's fairly simple to do from a code standpoint. You could just write a simple script called "TilingScaler" and have it automatically change the tile scaling to the size of the object on Start() or Awake(). Then by attaching that simple script your created platforms would always have proper tiling on their materials.

ErIog fucked around with this message at 09:12 on Apr 6, 2015

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