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
Nition
Feb 25, 2006

You really want to know?
I had that same problem a while ago so I feel your pain. I gave up making a custom inspector for it and just had it show both sets of options all the time (luckily I only had two options), even though half of them wouldn't be relevant.

Adbot
ADBOT LOVES YOU

KRILLIN IN THE NAME
Mar 25, 2006

:ssj:goku i won't do what u tell me:ssj:


Beer is not for children



edit:
https://www.youtube.com/watch?v=Zc6udR3VqK0


al-azad posted:

Beer is not for the shower.

I 100% disagree with this post.

KRILLIN IN THE NAME fucked around with this message at 13:13 on Aug 21, 2015

al-azad
May 28, 2009



Beer is not for the shower.

sighnoceros
Mar 11, 2007
:qq: GOONS ARE MEAN :qq:

al-azad posted:

Beer is not for the shower.

Wow look at how wrong you are.

Anyone doing LD33? Going to be my first LD, any tips? Probably only really going to have time to work on it Saturday for most of the day, then Sunday up into the late afternoon, so I think my timeline is going to have to be particularly condensed.

Shoehead
Sep 28, 2005

Wassup, Choom?
Ya need sumthin'?
I would but with work tomorrow and how things turned out with GBjam I think I need a bit of a break.

Nanomachine Son
Jan 11, 2007

!

sighnoceros posted:

Wow look at how wrong you are.

Anyone doing LD33? Going to be my first LD, any tips? Probably only really going to have time to work on it Saturday for most of the day, then Sunday up into the late afternoon, so I think my timeline is going to have to be particularly condensed.

I've only ever done the group one, the individual one seems really crazy to try and keep motivated to see it all the way through. I kind of want to do this one but most the people I know are busy and I have a bunch of travel in less than a week, if I really like the theme I might try and do something but I don't feel like investing too much time on it.

StickFigs
Sep 5, 2004

"It's time to choose."

dreamless posted:

Yeah, that's tricky. You can access fields that are part of serializable classes that aren't SerializableObjects through SerializableProperties, but you can't get a reference to the CommandParamPair object itself without doing some painful reflection stuff. I found this link in our custom editor code: http://answers.unity3d.com/questions/425012/get-the-instance-the-serializedproperty-belongs-to.html which might help.

But even if you manage to get that reference and use it to fill the object[] with data Unity won't know how to serialize it. If it was me I'd just make all the parameters you'd ever use: int1, int2, vector1, float1, etc. and have your custom inspector hide and zero out the ones that don't go with the enum you've chosen. It does feel kind of janky.

Hmm, does Unity serialize objects with it's own special serialization methods? Could I add the ability for Unity to serialize an object[]?

I feel like this stuff should have been doable in Unity out of the box...

Somfin
Oct 25, 2010

In my🦚 experience🛠️ the big things🌑 don't teach you anything🤷‍♀️.

Nap Ghost

sighnoceros posted:

Wow look at how wrong you are.

Anyone doing LD33? Going to be my first LD, any tips? Probably only really going to have time to work on it Saturday for most of the day, then Sunday up into the late afternoon, so I think my timeline is going to have to be particularly condensed.

I'm giving it a shot- looks like it's gonna be basic 2D Unity, off-centre pixel art and automatic hitboxes. Joy.

Stick100
Mar 18, 2003

sighnoceros posted:

Anyone doing LD33? Going to be my first LD, any tips?

Make something, anything and submit it. That should be your only goal. If you need a second one try to make it fun.

Find a concept quickly, try to make an engaging game as soon as your can then iterate and iterate on the fun. Don't worry about art quality or bugs until you have something that plays like a game.

Personally I used to submit bad games to LD but for the last few I get too in my headspace and don't like the quality so end up submitting nothing, don't be me!

Zaphod42
Sep 13, 2012

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

al-azad posted:

Beer is not for the shower.

This heathen doesn't know about shower beer :rolleyes:

ToxicSlurpee
Nov 5, 2003

-=SEND HELP=-


Pillbug

Zaphod42 posted:

This heathen doesn't know about shower beer :rolleyes:

The shower beer is the best thing.

Seriously.

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!
I have been doodling on a pseudo tile-based world editor for some time now, and centering my game around loading and running levels from it. It has data for walls surrounding the tiles in the four cardinal directions. When I started this, I was just using very regular, four-vertex planes, but have since started switching over to importing mesh data. That was a real adventure; think for a second what happens to all the triangle indices when you replace a wall of mesh X with a wall of mesh Y, having a different number of vertices.

Anyways, I'm trying to figure out how to lay this out in a UI. Is there something in the wild I could examine that has something for:

1. Picking different types of walls. That is, flat walls, doorways, slightly-decorated walls.
2. Apply different textures to them.

I'm thinking I just want one pane to pick the type of object, and another pane switch to the texture map that can be applied to the wall. That's what I'll do by default, but I would prefer to improve the user experience on the first attempt if there's anything out there that can improve on that basic premise.

StickFigs
Sep 5, 2004

"It's time to choose."
So I have this giant PlayerController.cs script in my Unity game and I'm trying to break it down in a smart way.

I'm thinking of keeping the PlayerController and moving movement stuff into PlayerMovement.cs, shooting logic into PlayerShooter.cs, etc. I'm getting a little foggy when it comes to deciding how all these will work together in Unity's Entity-Component-System. For example. I want to be able to edit the public properties of these individual scripts in the Unity editor inspector so I have them derived from MonoBehaviour. BUT I want the scripts to be able to communicate with each other so for example, if I want PlayerController to be where I keep the OnTriggerEnter() logic then I'd obviously want to be able to call PlayerMovement.DoFlinch() and PlayerHealth.TakeDamage() but I would have to cache a reference to every component with a GetComponent call and that feels weird because there's nothing guaranteeing that I remembered to attach the requested component to the Player GameObject.

Does it make more sense to use BroadcastMessage("OnHit") and not have to worry about what components are living on this GameObject?

I hope this gives an idea of what kind of design questions I have and what I'm looking for!

Nanomachine Son
Jan 11, 2007

!

Rocko Bonaparte posted:

I have been doodling on a pseudo tile-based world editor for some time now, and centering my game around loading and running levels from it. It has data for walls surrounding the tiles in the four cardinal directions. When I started this, I was just using very regular, four-vertex planes, but have since started switching over to importing mesh data. That was a real adventure; think for a second what happens to all the triangle indices when you replace a wall of mesh X with a wall of mesh Y, having a different number of vertices.

Anyways, I'm trying to figure out how to lay this out in a UI. Is there something in the wild I could examine that has something for:

1. Picking different types of walls. That is, flat walls, doorways, slightly-decorated walls.
2. Apply different textures to them.

I'm thinking I just want one pane to pick the type of object, and another pane switch to the texture map that can be applied to the wall. That's what I'll do by default, but I would prefer to improve the user experience on the first attempt if there's anything out there that can improve on that basic premise.

I've been screwing around with Unity trying to make something similar, the best I could think of was to make a series of prefabs that could be dragged into a palette and maybe try to draw the mesh in scene view as you try and place it. For the texture I figured it could be as simple as just setting a different material or some kind of offset if you're using a tilemap. It sounds like you have the right idea in general though it sounds like you're making your own tools from scratch not using an engine.

Not sure if it's quite what you're looking for but in terms of UI I always though the way blizzard made their tools for Warcraft / Starcraft was pretty intuitive. They'd always have stuff in a seperate window with different tooltips and previews and I believe you could add your own stuff to it using some internal DB tool? Best screenshot I could find of it: http://bradcook.net/games/articles/2002/08/warcraft3editor/images/hubshot1.jpg

Speaking of, is there any good way in Unity to have the OnSceneGUI function not be attached to a CustomInspector? I was able to get it working from a window by adding my own function to the delegate, but it's not documented and when it's used it manages to override everything, including Undo/Redo and the like. Makes it a real pain to work with.

StickFigs posted:

So I have this giant PlayerController.cs script in my Unity game and I'm trying to break it down in a smart way.

I'm thinking of keeping the PlayerController and moving movement stuff into PlayerMovement.cs, shooting logic into PlayerShooter.cs, etc. I'm getting a little foggy when it comes to deciding how all these will work together in Unity's Entity-Component-System. For example. I want to be able to edit the public properties of these individual scripts in the Unity editor inspector so I have them derived from MonoBehaviour. BUT I want the scripts to be able to communicate with each other so for example, if I want PlayerController to be where I keep the OnTriggerEnter() logic then I'd obviously want to be able to call PlayerMovement.DoFlinch() and PlayerHealth.TakeDamage() but I would have to cache a reference to every component with a GetComponent call and that feels weird because there's nothing guaranteeing that I remembered to attach the requested component to the Player GameObject.

Does it make more sense to use BroadcastMessage("OnHit") and not have to worry about what components are living on this GameObject?

I hope this gives an idea of what kind of design questions I have and what I'm looking for!

What we did for our game jam project was to use delegates and events, so we'd have the Player and then that'd have a Damageable component that we could look for an get a reference too at the start, usually with a way to add a generic Damageable component at runtime if one wasn't detected. Again, I don't know if it's exactly what you're looking for or if it might be something you'd already tried but it seemed to work for us. https://unity3d.com/learn/tutorials/modules/intermediate/scripting/events has some more details.

Nanomachine Son fucked around with this message at 18:11 on Aug 21, 2015

StickFigs
Sep 5, 2004

"It's time to choose."

TheOrange posted:

What we did for our game jam project was to use delegates and events, so we'd have the Player and then that'd have a Damageable component that we could look for an get a reference too at the start, usually with a way to add a generic Damageable component at runtime if one wasn't detected. Again, I don't know if it's exactly what you're looking for or if it might be something you'd already tried but it seemed to work for us. https://unity3d.com/learn/tutorials/modules/intermediate/scripting/events has some more details.

In my case events won't work because I need to be able to pass parameters. How did you leverage delegates though?

Nanomachine Son
Jan 11, 2007

!

StickFigs posted:

In my case events won't work because I need to be able to pass parameters. How did you leverage delegates though?

Actually you can set them up to let you pass parameters, you just set up the delegate like this (terrible code, might work but I'm pulling it out of my rear end)

code:
public delegate void OnHitByProjectileDelegate(Projectile proj); 
public event OnHitByProjectileDelegate OnHitByProjectileEvent;

public void SomeFunction() {
	OnHitByProjectileEvent += OnHitByProjectile;

	Projectile proj = new Projectile(); 
	HitByProjectile(proj);
}

public void OnHitByProjectile(Projectile proj) {
	Debug.Log("I was hit by a " + proj.type + " projectile");	
}
which would let you call it with parameters, in our case we were using something like that to detect when an enemy got hit with a specific type of projectile, so fire would light it on fire, ice would freeze, etc. It's something we didn't actually use in the final game but it at least seemed to work in case we wanted it. Our source code is available here, it's probably a complete mess but it might help? In particular we were using them as a convenient way to add things like hit points to any game object, then another component if it was something that was supposed to deal damage and so on. In retrospect it's not really the right place to be using delegates I guess but I just did it because it seemed convenient at the time I suppose. It's still something I'd probably use for handling more nebulous things like when a central handler needs to change state or something.

The only really weird thing I've run into with delegates in particular is that they don't get cleaned up properly when you reload a scene or reload scripts in the editor, so you have to specifically de-register them on a OnDestroy function.

Nanomachine Son fucked around with this message at 18:59 on Aug 21, 2015

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!

TheOrange posted:

I've been screwing around with Unity trying to make something similar, the best I could think of was to make a series of prefabs that could be dragged into a palette and maybe try to draw the mesh in scene view as you try and place it. For the texture I figured it could be as simple as just setting a different material or some kind of offset if you're using a tilemap. It sounds like you have the right idea in general though it sounds like you're making your own tools from scratch not using an engine.
I am using Unity, but it sure feels like I'm doing everything from scratch. The GUI code is sad. I had to make my own selection grid for the different tiles since the built-in grid view--or whatever it is called--is pretty weak.

quote:

Not sure if it's quite what you're looking for but in terms of UI I always though the way blizzard made their tools for Warcraft / Starcraft was pretty intuitive. They'd always have stuff in a seperate window with different tooltips and previews and I believe you could add your own stuff to it using some internal DB tool? Best screenshot I could find of it: http://bradcook.net/games/articles/2002/08/warcraft3editor/images/hubshot1.jpg
I do think of Blizzard's tools from those old days as being pretty close in terms of laying the stuff out. If that's the state of the art, then I guess I go from there.

quote:

Speaking of, is there any good way in Unity to have the OnSceneGUI function not be attached to a CustomInspector? I was able to get it working from a window by adding my own function to the delegate, but it's not documented and when it's used it manages to override everything, including Undo/Redo and the like. Makes it a real pain to work with.
I will actually look this up tonight because I think I did that for some of this. I have not implemented Undo/Redo yet. It did not like me the first time I tried.

Nanomachine Son
Jan 11, 2007

!

Rocko Bonaparte posted:

I am using Unity, but it sure feels like I'm doing everything from scratch. The GUI code is sad. I had to make my own selection grid for the different tiles since the built-in grid view--or whatever it is called--is pretty weak.
I do think of Blizzard's tools from those old days as being pretty close in terms of laying the stuff out. If that's the state of the art, then I guess I go from there.

I will actually look this up tonight because I think I did that for some of this. I have not implemented Undo/Redo yet. It did not like me the first time I tried.

Ah, ok. Yeah it leaves quite a bit to be desired, I look at some of the tools out there like ProBuilder though and it at least seems like you can leverage it in some interesting ways. I only got so far as making a tool that could instantiate new prefabs on the grid, but I figured if I could extend it into a window I could replicate the blizzard layout pretty easily. The problem was it disabled all the Unity built in stuff, even the settings for Skybox/Lighting in the scene view and all the keyboard controls, I ended up turning it into a toggle button instead but trying to fix mistakes got frustrating without Undo.

dreamless
Dec 18, 2013



StickFigs posted:

Hmm, does Unity serialize objects with it's own special serialization methods? Could I add the ability for Unity to serialize an object[]?

I feel like this stuff should have been doable in Unity out of the box...

It does. This Unity blog post is still the best description we've got. It made more sense when I learned that the inspector and saving assets to disk are built out of the same stuff, so if you've got two references to a custom class in your MonoBehaviour, it'll show up as two separate foldouts in the inspector and be saved out separately even if you point them to the same object; if you set it to null, it'll be loaded in with default values, just like it shows up in the inspector. If you make a Dictionary it won't show up or save, etc.

But if you have a reference to a Unity object (ScriptableObject/MonoBehaviour), it's stored as a reference, and you get the drag&drop/object picker box in the inspector. This is the only level where type information is saved.

You've got a lot of freedom to go against the grain of Unity, but there are rabbit holes you can fall down; I've definitely spent an hour to get to the "hey, I've dumped level data to json!" stage and then kept tinkering with the thing for weeks when I really just want to be working on the game.

FuzzySlippers
Feb 6, 2009

StickFigs posted:

Does it make more sense to use BroadcastMessage("OnHit") and not have to worry about what components are living on this GameObject?

I hope this gives an idea of what kind of design questions I have and what I'm looking for!

If you decide to go with this approach I'd take something like MessageKit and adapt it to be a local instance instead of a global static and use it to broadcast messages. I did something like that and it worked pretty well. So on Awake all the components that want to talk to each other can getcomponent the local message hub and then listen for messages and broadcast them. It also allowed other objects to getcomponent on a trigger hit or whatever and check for message hub on the hit gameobject and then send messages to it.

I'm really not a fan of ever using SendMessage or BroadcastMessage.

If you are just worried about remembering to attach components you could either use the RequireComponent tag or just have something fulfill the requirements on awake if it can't cache them. I tend to have a "BaseEntity" or "BaseCharacter" or whatever depending upon the game that things can getcomponent on and find all the usual components (movers, pathfinders, ITakeDamage, whatever) so they don't have to search for them all.

FuzzySlippers fucked around with this message at 22:00 on Aug 21, 2015

Nition
Feb 25, 2006

You really want to know?
I remembered something I did with Unity that helped in my case when I wanted sub-groups of parameters to activate. Although I had too much trouble getting it to only show one subset at a time, I managed to contain each set in its own separate expandable subset.

code:
[System.Serializable]
public class MySubclass {
	[SerializeField]
	int myParameter;
	[SerializeField]
	string myStringParameter;
}

public class MyMainClass {
	[SerializeField]
	MySubclass subParameters;
}
Basically, if you define a class as [System.Serializable], then its serialized parameters can show up in the Inspector when you assign it from another class. You can define the subclass inside the main class rather than separately if you like.

So if you have a class with lots of parameters, you can at least put some in a Serializable subclass and attach that instead, and Unity will give you like an expandable dropdown thing with those parameters inside it in the inspector.

StickFigs
Sep 5, 2004

"It's time to choose."
It sounds to me like this is indeed a rabbit hole and I will just make every CommandParamPair have 1 of each potentially needed data type and add more as I go.

It'll be ugly and confusing but it'll work!

StickFigs fucked around with this message at 00:39 on Aug 22, 2015

sighnoceros
Mar 11, 2007
:qq: GOONS ARE MEAN :qq:
What a horribly cliche theme.

edit for clarification: LD theme is "You are the monster" :(

sighnoceros fucked around with this message at 02:31 on Aug 22, 2015

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!

TheOrange posted:

Speaking of, is there any good way in Unity to have the OnSceneGUI function not be attached to a CustomInspector? I was able to get it working from a window by adding my own function to the delegate, but it's not documented and when it's used it manages to override everything, including Undo/Redo and the like. Makes it a real pain to work with.
It looks like I did not have a trick for this after all. The OnSceneGUI implementation I use is tied to a component representing my level data, and it includes some inspector code.

Nanomachine Son
Jan 11, 2007

!

Rocko Bonaparte posted:

It looks like I did not have a trick for this after all. The OnSceneGUI implementation I use is tied to a component representing my level data, and it includes some inspector code.

Yeah I found what I was using here, but it's some kind of internal thing that doesn't seem to have proper documentation. One thought might be to create a Camera when you focus an editor window and draw that to a texture but you'd then have to implement a lot of the panning around and such on your own.

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!
I might as well show what has been keeping me off the streets:

(clicky for animated)
Not shown is a separate palette editor that lets me drag and drop textures that can then be added on. Those solid colors are really textures, so I can make it work.

The user experience still sucks, and I realize I need to make a corner mesh for when two double-side walls meet at an angle. Also, the wall texture has an off-by-one problem; look at the white along the top of the walls. Finally, the preview wall is all broken. Oh well--at least I know some stuff to do.

I keep telling myself it's still work doing the level editing because a lot of that goes right into the game idea. The pathfinder uses the level representation already, and I use the same code for loading the level to edit as I do to make the final game mesh out of it. It's just reaching in and inserting/removing/replacing mesh data as necessary.

Omi no Kami
Feb 19, 2014


For those of you who have used unreal's Matinee system, is there any possible workflow that doesn't involve curating all of my cutscenes in the level blueprint? It seems like the entire system is built assuming that you want everything centralized, and it's not that hard to teach everything that needs to trigger a cutscene to find the persistent level and call an event, but it's a layer of abstraction that I don't need, and don't really wanna work around if I don't have to.

Edit: I noticed it's Saturday, so here's what I've been getting in on- working stamina, calendar, interactivity on any object (it's driving the speech here), and day/night cycle. I'm doing 1 action/period right now, but it cues off of the stamina system, so I'm pondering giving you multiple actions per period.

Omi no Kami fucked around with this message at 10:19 on Aug 22, 2015

Shoehead
Sep 28, 2005

Wassup, Choom?
Ya need sumthin'?

sighnoceros posted:

What a horribly cliche theme.

edit for clarification: LD theme is "You are the monster" :(

John you are the demons

mutata
Mar 1, 2003

Make an old school advertainment game where you play as a can of Monster energy drink.

Edit: but you end up inadvertently murdering some people and you have to cover it up by getting rid of the evidence.

Omi no Kami
Feb 19, 2014


This is incredibly silly, but one of the reasons I'm keen on adding multiple actions/day is for that very energy economy: something I loved about both Dead Rising 2 and Disaster: Day of Crisis was the way your guy would grab a giant cheeseburger/soft drink/steak, desperately plow through it in seconds, then return, refreshed, to the business of murdering zombies or saving accident victims.

There are lots of neat little stylistic flairs I could do with this too, like only letting you consume one item per period (for balance) and justifying that by having you carry it around with you, as if you're slowly dragging on your cigarette/pulling at your flask as you stomp around beating the streets.

Steampunk_Spoon
May 18, 2009
My last attempt at making a turn-based strategy game stalled out in a tangled mess of unityscript and spritesheets, so i figured i'd start over and learn a bit of C# while i'm at it. Also it's in 3D this time because having to create 4 sprites for each tile direction was driving me nuts.



I started with a tile-based level editor. It's clunky as poo poo but at least it forced me to work out how to structure and interact with my level data. Should probably look more interesting when i get some of my actual art in there too.

KiddieGrinder
Nov 15, 2005

HELP ME

drat skippy, very nice work.

Somfin
Oct 25, 2010

In my🦚 experience🛠️ the big things🌑 don't teach you anything🤷‍♀️.

Nap Ghost

sighnoceros posted:

What a horribly cliche theme.

edit for clarification: LD theme is "You are the monster" :(

Eh, I think that the people complaining just need to think through the theme a bit. It's extremely open to interpretation.

I'm going for 'use surreptitious influence to create a cult of sufficient size.' You have to sew horror in the streets of Almost-Innsmouth.

Nanomachine Son
Jan 11, 2007

!

Rocko Bonaparte posted:

I might as well show what has been keeping me off the streets:

(clicky for animated)
Not shown is a separate palette editor that lets me drag and drop textures that can then be added on. Those solid colors are really textures, so I can make it work.

The user experience still sucks, and I realize I need to make a corner mesh for when two double-side walls meet at an angle. Also, the wall texture has an off-by-one problem; look at the white along the top of the walls. Finally, the preview wall is all broken. Oh well--at least I know some stuff to do.

I keep telling myself it's still work doing the level editing because a lot of that goes right into the game idea. The pathfinder uses the level representation already, and I use the same code for loading the level to edit as I do to make the final game mesh out of it. It's just reaching in and inserting/removing/replacing mesh data as necessary.

Honestly that doesn't look too bad to me, you could probably do with having some keyboard shortcuts to put the camera in isometric mode and quickly rotate it. For my preview wall I was drawing some lines using Handles / Gizmos rather than try to draw up the entire mesh. Not quite sure what's going wrong with yours, I don't understand too much about making my own custom meshes so I doubt I can be much help there. The off-by-one thing seems like it might be a float to int conversion or if your texture is using some kind of filtering / anti-aliasing.

Also that GIF that Steampunk_Spoon posted looks slick as hell.

Somfin posted:

Eh, I think that the people complaining just need to think through the theme a bit. It's extremely open to interpretation.

I'm going for 'use surreptitious influence to create a cult of sufficient size.' You have to sew horror in the streets of Almost-Innsmouth.

The theme doesn't seem that bad but all my ideas for it are way more conceptual than having any basis in a mechanical sense. Doing something with influences from Alien or The Thing would be awesome but I have zero clue how you make that work mechanically for something that needs to be made in 48 hours.

Resource
Aug 6, 2006
Yay!

Steampunk_Spoon posted:

My last attempt at making a turn-based strategy game stalled out in a tangled mess of unityscript and spritesheets, so i figured i'd start over and learn a bit of C# while i'm at it. Also it's in 3D this time because having to create 4 sprites for each tile direction was driving me nuts.



I started with a tile-based level editor. It's clunky as poo poo but at least it forced me to work out how to structure and interact with my level data. Should probably look more interesting when i get some of my actual art in there too.

This looks really cool and useful :) Nice work.

PhantomZero
Sep 7, 2007

Bel Monte posted:

Edit: You know what? I think I really just fragmented everything too much. Again. Going to consolidate these things. I shouldn't be having to check ID's every step of the way. I did something very wrong to my variable organization.

So this is kind of a low level dumb question. But as I'm writing up code (in game maker if it makes a difference) and I'm thinking there has got to be a better/faster way of doing these basic tasks. Here's my conundrum, I used to have large arrays/databases that housed a LOT of variables, but now I have multiple arrays and databases with specialized variables they hold. They could grow or shrink dynamically, so the position of some things can and will change. I have IDs for products, regions they are sold in, and then who they are sold to (different types of consumers).

So I have to match the product ID between arrays, match the region ID's so I don't apply the wrong math to the wrong region, then iterate through the consumer types applying proper multipliers for who's interested (which draws from two separate arrays/databases which I then need to match the ID's with too). Will I just have to loop through everything in an entire array/database one step at a time, or is there a better way to organize this?

I'm definitely confusing myself a lot, as I thought breaking down a lot of my originally large arrays/databases into more bite sized chunks would make things easier... Or at least simpler to work with. It's proven to be the opposite. :(
I'm at the point where I think just going back to slightly cluttered but massive arrays/databases would be better for everything involved than the mess of checking for IDs that I've put myself in now.

This just sounds messy and I dont really understand what you are trying to do. But if all you are doing is searching through an array you can use Divide and Conquer techniques or multi threading to return an answer faster.

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!

TheOrange posted:

The off-by-one thing seems like it might be a float to int conversion or if your texture is using some kind of filtering / anti-aliasing.
I saw what the problem was while dealing with being able to reassign UVs when applying a new texture to a piece of a wall. The textures are stuffed into a larger atlas texture. Each subtexture in that atlas gets a 32x32 region right now, but it's not hard-coded. Anyways, when it's translating, it winds up taking a region of, say (0,0)->(32,32) instead of (0,0)->(31,31). At least I'm pretty sure that's how I'm getting those stripes.

Bel Monte
Oct 9, 2012

PhantomZero posted:

This just sounds messy and I dont really understand what you are trying to do. But if all you are doing is searching through an array you can use Divide and Conquer techniques or multi threading to return an answer faster.

Basically, I have too many separate arrays for my liking.

In order to modify one small value, I have to run through several ID matching between the arrays to make sure I'm on the correct value to change. So instead of just matching an ID number once, I need to do it multiple times for multiple arrays just to do anything simple, let alone complex.

And I don't know if there's a faster way to find an ID number in an array other than to loop through the entire thing. So I loop through multiple arrays every time I want to find anything.

To me, this is a recipe for major slowdown and unnecessarily large code for simple tasks. It may just be faster if the arrays are larger and a little cluttered than to cleanly separate values into categories of arrays.

Edit: I originally did this because it looked nice and simple (an array for population, product stats, product sales, etc), until I started to try and have the program modify these arrays. So I really do think I went overboard... Unless there's a faster method I'm not aware of?

Bel Monte fucked around with this message at 19:58 on Aug 22, 2015

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!
What kind of padding and fudging do I have to do in order to align textures well? I was working on my off-by-one problems with that level editor. My texture atlas is using a 256x256 texture, and the tiles inside are each getting a 32x32 region. Part of my problem was the UV mapping was assuming using a 0,0 -> 32,32 mapping instead of 0,0 -> 31, 31. However, that actually did not completely fix things. It looked like I had to do some some further fudging. It looks like I'm clear with something like 1,1 -> 31,31, but I'm losing a whole texture's pixel that way. I'm assuming I really need to do something like 0.1, 0.1 -> 30.9, 30.9, but I wanted to ask for pointers before just toying with it a bunch.

I also noticed in Unity that I get into issues with faces hitting each other. Currently, my walls are three-dimensional and have edges on all sides. When I put two wall pieces next to each other, the leftmost wall's right side is touching the rightmost wall's left side. It looks like this causes some artifacting. I guess in the long term that I should just get rid of these surfaces, but I wondered if there was a mode or something I could toggle to reduce the artifacting.

Adbot
ADBOT LOVES YOU

SuicideSnowman
Jul 26, 2003

Bel Monte posted:

Basically, I have too many separate arrays for my liking.

In order to modify one small value, I have to run through several ID matching between the arrays to make sure I'm on the correct value to change. So instead of just matching an ID number once, I need to do it multiple times for multiple arrays just to do anything simple, let alone complex.

And I don't know if there's a faster way to find an ID number in an array other than to loop through the entire thing. So I loop through multiple arrays every time I want to find anything.

To me, this is a recipe for major slowdown and unnecessarily large code for simple tasks. It may just be faster if the arrays are larger and a little cluttered than to cleanly separate values into categories of arrays.

Edit: I originally did this because it looked nice and simple (an array for population, product stats, product sales, etc), until I started to try and have the program modify these arrays. So I really do think I went overboard... Unless there's a faster method I'm not aware of?

As long as you're dealing with an ID that is always unique, why not use a dictionary: https://msdn.microsoft.com/en-us/library/xfhwa508%28v=vs.110%29.aspx

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