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
Unormal
Nov 16, 2004

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

SlightlyMadman posted:

Ah thank you! That's exactly what I was hoping to hear.

Right click on the inspector tab and select Debug and you can even see private fields ;)

Adbot
ADBOT LOVES YOU

Shalinor
Jun 10, 2002

Can I buy you a rootbeer?

Unormal posted:

Right click on the inspector tab and select Debug and you can even see private fields ;)
:aaa:

I'd been making specific public debug variables, to get around this. NICE.

Azazel
Jun 6, 2001
I bitch slap for a living - you want some?

Unormal posted:

Right click on the inspector tab and select Debug and you can even see private fields ;)

Holy poo poo. I never knew that existed.


Also: Thanks to all the previous comments about basic rotation logic. I was able to figure it out.

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!

Shalinor posted:

:aaa:

I'd been making specific public debug variables, to get around this. NICE.
I also say this same comment. Thanks Unormal. Looks like this is something they should be emphasizing in a tutorial somewhere!
Edit: or just making this the default because what the hell are you doing in the inspector if not debugging? (when the program is running)

roomforthetuna fucked around with this message at 02:56 on Mar 28, 2013

Unormal
Nov 16, 2004

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

roomforthetuna posted:

I also say this same comment. Thanks Unormal. Looks like this is something they should be emphasizing in a tutorial somewhere!
Edit: or just making this the default because what the hell are you doing in the inspector if not debugging?

Inspecting. :eyepop:

Unormal
Nov 16, 2004

Mod sass? This evening?! But the cakes aren't ready! THE CAKES!
Fun Shoe
Wow you can even swap the "Player Settings" into debug mode and edit the iOS/Wii/Xbox/etc settings on PC... and it has Metro settings in it...

Shalinor
Jun 10, 2002

Can I buy you a rootbeer?

Unormal posted:

Wow you can even swap the "Player Settings" into debug mode and edit the iOS/Wii/Xbox/etc settings on PC... and it has Metro settings in it...


Metro is in beta right now, and you can request access to it.


EDIT: VV The OP of the Making Games Megathread has the best one I know of. I'm @glassbottommeg.

Shalinor fucked around with this message at 02:37 on Mar 29, 2013

Unormal
Nov 16, 2004

Mod sass? This evening?! But the cakes aren't ready! THE CAKES!
Fun Shoe
Is there like a list of SA game-dev'ers twitter handles somewhere?

I'm @unormal if anyone wants to be my NEW BEST FRIEND.

V Ah, cool!

Unormal fucked around with this message at 02:43 on Mar 29, 2013

xzzy
Mar 5, 2009

Unormal posted:

Is there like a list of SA game-dev'ers twitter handles somewhere?

I'm @unormal if anyone wants to be my NEW BEST FRIEND.

There's a list in the making games megathread:

http://forums.somethingawful.com/showthread.php?threadid=3506853

Yodzilla
Apr 29, 2005

Now who looks even dumber?

Beef Witch
Question about Unity and Futile and shaders. We're planning on making multiple time of day versions of our levels. Now I know that Futile has shader support so I think I can add subtle tinting to objects to simulate this. I've also heard that this can cause some performance issues if there's too much going on but is that preferable to having repeated assets in multiple atlases? Here are some simple sample assets we're working with:



How would I go about writing a shader to, say, add a slight blue tint for a night scene or orange for a sunset?

cowboy beepboop
Feb 24, 2001

Has anyone had any experience with UI libraries for Monogame? There seems to be quite a few under heavy development, but no clear favourite, sound about right?

Chunderstorm
May 9, 2010


legs crossed like a buddhist
smokin' buddha
angry tuna

Torch Dexter posted:

Assuming everything else is correct - this would be your problem. Usually I'd pass the Type of the object to GetComponent() - until I went and checked the Unity documentation just now I didn't know you could pass it a script name in a string instead. Anyway - if passing a string as the parameter you should drop the .cs from the end and it seems it should work.

To be honest though, you should probably just pass the type of the object - and then the cast would be unnecessary.

so:

code:
s = g.GetComponent<statHolder>();
		or
s = g.GetComponent("statHolder") as statHolder;
Edit: Whoops - Corrected for C# Syntax instead of original JS

That seemed to work, though now I'm getting a null reference in my GetTurnOrder() method.
e: tables

code:
public void GetTurnOrder()
{
	//used to pull the high-speed game object out of the foreach loop without breaking it
	GameObject currentHighSpeed = null;
	
	//for loop based on how many battlers there are
	for (int i = 0; i < numberOfBattlers; i++)
	{
		// checking to see who is the highest speed through lowest speed
		foreach (GameObject g in battleParticipantsUnsorted)
		{
			statHolder s; //script variable, statHolder is the type, s is the name
       			s = g.GetComponent<statHolder>() as statHolder; // gets the script from the current game object

			// removed if (speed == 0) {g.SetActive(false);}
			
			if ((s.speed > tempHighSpeed) && (s.sortedInTurnOrder = false))
			{
				// if this participant is fast and unsorted, assign it as fastest and 
				// pull it out of the loop as gameObject currentHighSpeed
				tempHighSpeed = s.speed;
				currentHighSpeed = g;
			}
	}
	// now that the foreach loop is over, we have the fastest previously unsorted battle participant
	statHolder b; 
	b = currentHighSpeed.GetComponent<statHolder>() as statHolder;
	b.sortedInTurnOrder = true; // makes this bool true, meaning it will get skipped in the else if
	battleParticipants[turnOrderCounter] = currentHighSpeed; // current participant with highest speed gets sorted
	turnOrderCounter++; // gets us to the next space in the battleParticipants[] array
	}
}
I'm getting it at b = currentHighSpeed.GetComponent<statHolder>() as statHolder;

As far as I can tell currentHighSpeed should get assigned a value, but doesn't. After setting some break points and all that, I found that it doesn't even go into the if statement. From the values I've set in the inspector, all the gameObjects' sortedInTurnOrder bools are set to false, and their speeds are set from 1-8. I've tried setting some break points in Mono but I never really get a chance to step through my code. Am I doing something wrong there? I only learned where my problems were by using Debug.Log()

HappyHippo
Nov 19, 2003
Do you have an Air Miles Card?
Maybe I'm missing something, but where is tempHighSpeed declared? Shouldn't be reset before you begin your search? Maybe I'm misreading the intention of your code. If it's declared outside the method then I can see how after a second run of that method, without it being reset, "s.speed > tempHighSpeed" will never evaluate as true and currentHighSpeed will be null.

Definitely try to get the debugger working. Have you set a breakpoint at the entry of the method?

Edit: I think I was misreading this because of the indentation but I still feel there's something wrong with tempHighSpeed.

HappyHippo fucked around with this message at 22:08 on Mar 30, 2013

Chunderstorm
May 9, 2010


legs crossed like a buddhist
smokin' buddha
angry tuna
Yeah I have. No dice. I'm not too familiar with Mono's inner workings. And sorry, earlier in the class, in the Start() method, int tempHighSpeed gets declared and set to 0. Though you are right, after all that is said and done, it should definitely be reset to 0.

e: And thank you to all you guys that have helped. You're the best.

Chunderstorm fucked around with this message at 23:49 on Mar 30, 2013

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!

HarkToTheLoons posted:

Yeah I have. And sorry, earlier in the class, in the Start() method, int tempHighSpeed gets declared and set to 0. Though you are right, after all that is said and done, it should definitely be reset to 0.
Should probably be a local variable rather than a member variable, too, unless it's doing something elsewhere, which would be unusual for a variable with 'temp' in its name.

Torch Dexter
Dec 3, 2006

HarkToTheLoons posted:


code:
	if ((s.speed > tempHighSpeed) && (s.sortedInTurnOrder = false))
Glancing at the rest of the code, it seems like it should probably work. This line will need fixing though. You're assigning a value to a variable when you want to be checking it instead.

code:
(s.sortedInTurnOrder = false)
 //should be
(s.sortedInTurnOrder == false)

Chunderstorm
May 9, 2010


legs crossed like a buddhist
smokin' buddha
angry tuna

Torch Dexter posted:

Glancing at the rest of the code, it seems like it should probably work. This line will need fixing though. You're assigning a value to a variable when you want to be checking it instead.

code:
(s.sortedInTurnOrder = false)
 //should be
(s.sortedInTurnOrder == false)

I uh...

:suicide:

Clearly I've been looking at this code for too long to not catch that. That fixed the issue. Thanks for your help!

thegasman2000
Feb 12, 2005
Update my TFLC log? BOLLOCKS!
/
:backtowork:
Anyone making games in stencyl? Need a thread for it I reckon as it's got a really small entry requirement but allows actionscript 3 coding for custom functions.

Grace Baiting
Jul 20, 2012

Audi famam illius;
Cucurrit quaeque
Tetigit destruens.



HarkToTheLoons posted:

I uh...

:suicide:

Clearly I've been looking at this code for too long to not catch that. That fixed the issue. Thanks for your help!

When working in a language that allows you to use the assignment operator from within a condition statement (i.e. basically everything besides Python that I know of), you can do this ugly-but-safer syntax:
code:
if (false = s.sortedInTurnOrder)  // can't assign to a literal, will instead immediately fail at this error!
if (false == s.sortedInTurnOrder) // hooray!
So yeah it's less pretty and a little less intuitive (to me at least) but can make your poo poo less error-prone. It works for basically anything where you want to be doing an equality test with a literal or a const or anything else that can't be assigned to.

HappyHippo
Nov 19, 2003
Do you have an Air Miles Card?
That looks like C#. Doesn't C# give you a warning when you compile with if(a = false)?

Also, since C# won't cast expressions to booleans implicitly this only comes up if you're testing booleans, so you can avoid the issue entirely by doing if(a) or if(!a)

The Gripper
Sep 14, 2004
i am winner

HappyHippo posted:

That looks like C#. Doesn't C# give you a warning when you compile with if(a = false)?

Also, since C# won't cast expressions to booleans implicitly this only comes up if you're testing booleans, so you can avoid the issue entirely by doing if(a) or if(!a)
C# will happily compile something like that without a warning, at least in whatever of VS I'm using now.

Tres Burritos
Sep 3, 2009

Abjad Soup posted:

When working in a language that allows you to use the assignment operator from within a condition statement (i.e. basically everything besides Python that I know of), you can do this ugly-but-safer syntax:
code:
if (false = s.sortedInTurnOrder)  // can't assign to a literal, will instead immediately fail at this error!
if (false == s.sortedInTurnOrder) // hooray!

This ... this is really smart. Why did no one tell me this?

HappyHippo
Nov 19, 2003
Do you have an Air Miles Card?

The Gripper posted:

C# will happily compile something like that without a warning, at least in whatever of VS I'm using now.

I get "Warning Assignment in conditional expression is always constant; did you mean to use == instead of = ?" It also underlines the code in question to indicate a warning.

http://msdn.microsoft.com/en-us/library/c1sde1ax(v=vs.71).aspx

That Turkey Story
Mar 30, 2003

Tres Burritos posted:

This ... this is really smart. Why did no one tell me this?

I'm going to be the jerk that points out that if you can remember to put a constant on the left side, how is that any different from remembering to be certain to put == instead of =? Also, not all comparisons have a constant operand. It's not really "safer," it's just cargo-cultish.

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!

That Turkey Story posted:

I'm going to be the jerk that points out that if you can remember to put a constant on the left side, how is that any different from remembering to be certain to put == instead of =? Also, not all comparisons have a constant operand. It's not really "safer," it's just cargo-cultish.
To be fair, it's hard to make a habit of typing "==" when you often actually need to type "=", whereas it's relatively easy to make a habit of putting the "low priority" comparators first because you rarely need to put them second. (I say "low priority" because yeah, sometimes there's no constant operand, and it would tend to fray the habit if you don't have something consistent there.)

And if you make that a habit then it might sometimes catch a typo for you.

But I agree that it's really probably more trouble than it's worth and tends to make the code less intuitive to read. In that respect it's similar to endorsing "x.multiply(y.add(5))" over overloading operators.

SlightlyMadman
Jan 14, 2005

Am I the only one who would type that as "if (!s.sortedInTurnOrder)"?

1337JiveTurkey
Feb 17, 2005

SlightlyMadman posted:

Am I the only one who would type that as "if (!s.sortedInTurnOrder)"?

That's the preferred way to write it in most languages. If the language also doesn't implicitly cast to boolean or doesn't return a value from assignment, then the issue should never show up in the first place.

Polio Vax Scene
Apr 5, 2009



No, you are not. I haven't found a reason to use == for bools.


Tres Burritos posted:

This ... this is really smart. Why did no one tell me this?

Some 'languages' (GML :argh:) will let you use = in a conditional statement and still treat it like a conditional instead of an assignment. However this is one of those things you learn in week 1 of csci 101 so most people probably just take it for granted.

Also, visual studio 2010 SP1 definitely does not let you use = in a conditional statement.

Sarcophallus
Jun 12, 2011

by Lowtax
To get back to game talk for a moment, I want to make a top down 3D game (think Alien Swarm), but I need deformable geometry and a pretty decent physics engine. I've done a bit of searching, but haven't come up with much - is there a decent engine out there that would suit my needs? I'm not really interested in engines like Unity, I'd prefer something that's more code-heavy.

Orzo
Sep 3, 2004

IT! IT is confusing! Say your goddamn pronouns!
I have a limited knowledge of Unity, but my impression is that it is code heavy.

Grace Baiting
Jul 20, 2012

Audi famam illius;
Cucurrit quaeque
Tetigit destruens.



I called it less intuitive because it doesn't follow the way I (and I'd imagine most people) phrase the condition in my own head, which is "is $RELEVANT_VAR the same as $TARGET_VALUE?". The reversed condition will probably break consistency with your other conditions, which presumably are in "variable, value" order. And as I noted, it only helps when you are doing exact equality testing between a variable and an immutable value.

It's no magic bullet but it can be very handy on occasion (albeit, as noted, not necessarily when comparing to booleans).

Shalinor
Jun 10, 2002

Can I buy you a rootbeer?

Orzo posted:

I have a limited knowledge of Unity, but my impression is that it is code heavy.
It is. There are toolsets you can use to work around that, and you can hack together prototypes without a ton of code, but... do not get it thinking it's a magical WYSIWYG game maker. It's not that at all.

For that, you'll want to go with Stencyl. Arguably, even UDK is a better option - vertical learning curve, but Kismet is powerful and visual.

Anyways, if you want a multiplatform engine that's UI-light / code-driven, look into Moai.

Shalinor fucked around with this message at 18:20 on Apr 1, 2013

Sarcophallus
Jun 12, 2011

by Lowtax

Orzo posted:

I have a limited knowledge of Unity, but my impression is that it is code heavy.

I've played around with it and all I got out of it was that it was a what-you-see-is-what-you-get editor with scripted objects. Contrast with Source where you have the actual game code in front of you in visual studio. Granted my Unity knowledge is limited, I'll revisit it if it's heavily suggested.

Paradoxish
Dec 19, 2003

Will you stop going crazy in there?

Orzo posted:

My (C#) game engine uses Lua scripts for all game logic. I am considering switching to C# scripting for a number of reasons. Does anyone have any good (preferably highly technical) articles on how Unity does this? I have an idea on how to go about accomplishing what I need (aggregate all scripts and use CSharpCodeCompiler to dynamically generate an assembly) but I want to see if there's any gotchas or concepts that I haven't considered yet.

I don't suppose you've turned up any resources on this? I'm actually in the process of doing something similar (my game's "events" are scripted in C#), and I've been trying to find best practices or at least good examples of using C# as an embedded scripting language inside a C# program. I sort of just charged ahead and did my own thing, but I'd definitely feel a lot more comfortable if I could see how other people approached this. What I have right now looks more like a plugin system than an actual scripting engine.

Orzo
Sep 3, 2004

IT! IT is confusing! Say your goddamn pronouns!

Paradoxish posted:

I don't suppose you've turned up any resources on this? I'm actually in the process of doing something similar (my game's "events" are scripted in C#), and I've been trying to find best practices or at least good examples of using C# as an embedded scripting language inside a C# program. I sort of just charged ahead and did my own thing, but I'd definitely feel a lot more comfortable if I could see how other people approached this. What I have right now looks more like a plugin system than an actual scripting engine.
I didn't really turn up any resources, but I've almost finished my conversion to C# as the 'scripting' language. I put 'scripting' in quotes because, like you, it feels more like a plugin system. I'll eventually write a blog post or something about what I did, but here's the gist of it:

I have a main project for the game engine and a project for the game implemention (which is where all game-specific behaviors go). Both reference an assembly with various shared interfaces. The game engine dynamically loads the implementation assembly (via Assembly.Load) and uses reflection to create a 'behavior store'--that is, it finds all classes that implement some interface (IBehavior) defined in the game implementation assembly. From then on, those behaviors can be used as templates (by name; IBehavior requires you provide a unique name) to control the behavior of entities. The behavior object itself contains definitions about the object's...well, behavior (init, update, collide, custom triggers, etc), as well as the different states (if the entity needs a state machine) of the entity.

I haven't done this part yet, but the level editor will also use reflection to find all available behavior templates and present that as a list that the level designer can choose from to be stored in data on the entity (as a string). I'll also have support for custom properties that can be defined on the behavior templates, which the editor will know how to create controls for modifying.

If you want any more details I'd be glad to share via PMs or chat or whatever. I am pretty happy with how it's going so far--using C# is just infinitely better than using lua. I'm not even using compiler services at the moment, although it wouldn't be too difficult to convert to that later.

OneEightHundred
Feb 28, 2008

Soon, we will be unstoppable!
Re: C# scripts, Mono.CSharp.Evaluator and Microsoft.CSharp.CSharpCodeProvider may do what you want, but I've read some stuff that suggests they might only work for users with the Mono SDK installed, so if you're doing things in a way where the scripts have any kind of permanence (i.e. you're using them to script level events), you should probably implement them in a way that they're fixed in a release build.

i.e. something like, in the dev build, have a method that loads a script from a file given a string, but have the release build convert the script files into wrapped-up static methods at build time and look them up using some mapping or other of the filename to the static methods.

OneEightHundred fucked around with this message at 18:47 on Apr 1, 2013

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!

Sarcophallus posted:

I've played around with it and all I got out of it was that it was a what-you-see-is-what-you-get editor with scripted objects. Contrast with Source where you have the actual game code in front of you in visual studio. Granted my Unity knowledge is limited, I'll revisit it if it's heavily suggested.
"Scripted objects" are made of game code, which you can have open in visual studio if you want (though the editor that comes with Unity is fine).

Unity does kind of have that WYSIWYG editor front-and-center, but it's not really significantly different from having code and a level editor. You don't have to use the editor at all, you can dynamically generate your levels (and GUIs) from code if you prefer.

The thing that is different from a lot of engines is the component system, which is really great for anything at all complicated.

Sarcophallus
Jun 12, 2011

by Lowtax

roomforthetuna posted:

"Scripted objects" are made of game code, which you can have open in visual studio if you want (though the editor that comes with Unity is fine).

Unity does kind of have that WYSIWYG editor front-and-center, but it's not really significantly different from having code and a level editor. You don't have to use the editor at all, you can dynamically generate your levels (and GUIs) from code if you prefer.

The thing that is different from a lot of engines is the component system, which is really great for anything at all complicated.

I didn't know that, actually. So could I generated mostly-random geometry, like rooms, with textures in place, or does it have to use pre-fabricated objects?

Shalinor
Jun 10, 2002

Can I buy you a rootbeer?

Sarcophallus posted:

I didn't know that, actually. So could I generated mostly-random geometry, like rooms, with textures in place, or does it have to use pre-fabricated objects?
You can generate as much or as little as you like. For sanity's sake, I'd usually recommend generating out of object chunks / decoration objects, but that's more because pure procedural usually looks and plays like rear end.

Jones On Fire is entirely procedural, for instance. If you load the main scene up in Unity, all you see is a player. All the level geometry is loaded/positioned/etc'ed at runtime.

Adbot
ADBOT LOVES YOU

xzzy
Mar 5, 2009

I just wish 90% of Unity's documentation wasn't in a forum somewhere. :geno:

answers.unity3d.com is one of my top visited sites lately.

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