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

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

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

the posted:

I have 100 red spheres named sphereRed and 100 blue spheres named sphereBlue. I don't see how it's feasible to give them all different names because ... well.. that seems like it would take awhile.
What is it that you're trying to do by giving them different names? Why do you want to give them different names? You were asking about using the applied color to distinguish whether a sphere is red or blue, I thought, and I said you could just use the name to distinguish that. You don't need them all to have different names for this, you can use the existing name, "sphereRed" or "sphereBlue". It would actually confound this to give them all different names. Why are we even taking about giving them all different names?

Adbot
ADBOT LOVES YOU

xzzy
Mar 5, 2009

roomforthetuna posted:

What is it that you're trying to do by giving them different names? Why do you want to give them different names? You were asking about using the applied color to distinguish whether a sphere is red or blue, I thought, and I said you could just use the name to distinguish that. You don't need them all to have different names for this, you can use the existing name, "sphereRed" or "sphereBlue". It would actually confound this to give them all different names. Why are we even taking about giving them all different names?

Probably because I brought it up due to not being clear on what he was trying to accomplish. He asked about how to tell two spheres apart that have the same name, so I suggested unique names.

poemdexter
Feb 18, 2005

Hooray Indie Games!

College Slice
The OnCollision override exists on every single sphere anyway so it's already easy to tell the spheres apart. One is the collision parameter passed on the event and the other is the sphere that has had it's OnCollision event fired.

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!

poemdexter posted:

The OnCollision override exists on every single sphere anyway so it's already easy to tell the spheres apart. One is the collision parameter passed on the event and the other is the sphere that has had it's OnCollision event fired.
Except that happens both ways around when there's a collision, which is why some way of distinguishing them is needed. But it doesn't need to be a way of identifying the specific red sphere, just deciding which one is more important. Comparing unique IDs seems like the best way, unless one of the goals is to have the same setup always play out identically, in which case using Unity's built in physics at all is probably a horrible idea.

xzzy
Mar 5, 2009

Since the sphere size is all he really cares about, I think a single if statement fixes all that.. both spheres test which one is bigger, and the smaller guy destroys himself. As a bonus I think that helps avoid race conditions if there's ever multiple collisions.

the
Jul 18, 2004

by Cowcaster

roomforthetuna posted:

Except that happens both ways around when there's a collision, which is why some way of distinguishing them is needed. But it doesn't need to be a way of identifying the specific red sphere, just deciding which one is more important. Comparing unique IDs seems like the best way, unless one of the goals is to have the same setup always play out identically, in which case using Unity's built in physics at all is probably a horrible idea.

It doesn't matter if it plays out differently each time. How do I compare UniqueIDs?

So I have the object.getinstanceid command. I'm trying to figure out how to use it.

I would getinstanceid of "this sphere," and then I would getinstanceid of "that sphere." Then I could use that as the first condition! Instead of using the velocity scalar, I can just compare instanceIDs. If one is larger, then that one "wins." Then, after that, I can use size.

Okay, now to figure out how to actually do this. Thanks so much guys, sorry for taking up so much of the thread. I'll post what I have when I get it written up.

Orzo
Sep 3, 2004

IT! IT is confusing! Say your goddamn pronouns!
If I'm not mistaken, you don't want to use instanceID at all unless there's a 'tie' in all other situations.

1. Are the sizes different? The bigger one wins.
2. Are the sizes the same, but the speeds are different? The faster one wins.
3. Same size, same speed--now what? Need a tiebreaker. Use the one with the greater instanceID.

You should use pastebin and paste some source code, it's much easier to help when there's actual code in front of you!

KoRMaK
Jul 31, 2012



the posted:

It doesn't matter if it plays out differently each time. How do I compare UniqueIDs?

So I have the object.getinstanceid command. I'm trying to figure out how to use it.

I would getinstanceid of "this sphere," and then I would getinstanceid of "that sphere." Then I could use that as the first condition! Instead of using the velocity scalar, I can just compare instanceIDs. If one is larger, then that one "wins." Then, after that, I can use size.

Okay, now to figure out how to actually do this. Thanks so much guys, sorry for taking up so much of the thread. I'll post what I have when I get it written up.
I'm not sure if anyone else has felt this way, but I am having a hard time understanding your issue because it seems like what you want is flip-flopping.

Why does the uniqueness of the sphere matter? In my concieved collision detection it doesn't.

code:
function OnCollisionEnter(_collision : Collision) {
  if(this.tag == "redSphere" && _collision.collider.parent.tag == "redSphere")
  {
   //we have to red spheres, find out which is bigger
   if( this.volume > _collision.collider.volume)
   {
      //this is bigger than the colliding object
   }
  }
}

the
Jul 18, 2004

by Cowcaster
^The check is going to go as follows:

Did you hit a red sphere? If so, go to the next condition

Are you larger? If so, you grow larger and destroy the other sphere. If you're the same size, go to the next condition

Is your instance ID larger (just an arbitrary check)? If so, grow larger and destroy the other sphere.

xzzy
Mar 5, 2009

the posted:

^The check is going to go as follows:

Did you hit a red sphere? If so, go to the next condition

Are you larger? If so, you grow larger and destroy the other sphere. If you're the same size, go to the next condition

Is your instance ID larger (just an arbitrary check)? If so, grow larger and destroy the other sphere.

It might be better to just pick randomly for the third check then.

code:
    if (Random.value >= 0.5)    {
        //destroy me
    } else {
        //destroy other guy, get bigger
    }
Since that's basically what comparing the unique id will accomplish.. the player won't have any idea why one sphere was picked over another.

the
Jul 18, 2004

by Cowcaster
Here's my broke code Pastebin: http://pastebin.com/b9Kqx74y

The IF statements comparing the size are incomplete because I don't know how to reference the colliding gameobject's scale. If anyone could take a look at it, that'd be awesome. Thanks.

^I might try that.

edit: What I mean is, I can use transform.localscale to find THIS object's size, but how do I find THAT object's size? collision.gameobject.transform.localscale is not a thing, obviously. So I don't know how to reference the object I collided with and to find it's size.

the fucked around with this message at 19:52 on Jul 25, 2013

KoRMaK
Jul 31, 2012



the posted:

Here's my broke code Pastebin: http://pastebin.com/b9Kqx74y

The IF statements comparing the size are incomplete because I don't know how to reference the colliding gameobject's scale. If anyone could take a look at it, that'd be awesome. Thanks.

^I might try that.
The operation you are looking for here is known as "casting". But in Unity it's a little easier
col.GameObject.transform.localscale should work. (I'm not in front of my Unity dev station right now)

You should probably set a debug point at that collision handler and inspect the variables that you can get at runtime. That is the single most helpful thing I've ever done: being able to see what is available at runtime.

the
Jul 18, 2004

by Cowcaster

KoRMaK posted:

You should probably set a debug point at that collision handler and inspect the variables that you can get at runtime. That is the single most helpful thing I've ever done: being able to see what is available at runtime.

And I have no idea what that sentence means.

Orzo
Sep 3, 2004

IT! IT is confusing! Say your goddamn pronouns!

xzzy posted:

It might be better to just pick randomly for the third check then.

code:
    if (Random.value >= 0.5)    {
        //destroy me
    } else {
        //destroy other guy, get bigger
    }
Since that's basically what comparing the unique id will accomplish.. the player won't have any idea why one sphere was picked over another.
If I recall correctly, the root of the issue is that the collision event gets fired on BOTH spheres, so he needs a way to *consistently* determine a winner from the perspective of either instance.

That is, the code should be
code:
if (I win the battle)
  Destroy other, make myself grow
else
  Do nothing, the other collision event will take care of business.

the posted:

And I have no idea what that sentence means.
Visual Studio has a very intuitive and excellent suite of debugging tools. Google 'debugging unity' and I'm sure you can find some tutorials on how to attach the debugger to your game. When it's attached, you can literally just drill into your objects and see all of their values and methods, and even call those methods while the game is paused. What he meant is that it's a great way to explore and API.

KoRMaK
Jul 31, 2012



the posted:

And I have no idea what that sentence means.
Ah so you know not the wonders of interactive debugging? It's a little different in Unity and I'd upload a gif demo of it but I don't have Unity installed, so here is a text description:
1) in Monodevelop (and only Monodevelop) there is an icon that looks like a plug in the toolbar, when you hover over it the tooltip says "attach to process" or something like that. "attach to" will be in there.
2)click that button
3)a window with available Unity things to attach to will be available, attach to the only one available
4)set a breakpoint at the first line in the collision handler by right clicking the line and selecting breakpoint or clicking in the margin
5) go back to Unity and press the play button, when the objects collide the game will pause and monodevelop will be paused at that line. You can then evaluate variables

PiCroft
Jun 11, 2010

I'm sorry, did I break all your shit? I didn't know it was yours

I have a question for a project I'd like some knowledgeable folks to give me some input on.

Over in the Cataclysm thread, I'm working on a system to provide electricity, so a survivor can build a generator, lay cables and power various devices. I'm considering methods to propagate power through cables at the moment and was wondering what kind of methods people would recommend.

For reference, its a roguelike, and I'm only considering the 4 cardinal directions so its fairly conceptually simple but I'd like it to be as efficient and robust as possible.

My current method involves, on each update, sending a on/off signal from power source objects. This would propagate recursively, skipping nodes that have already been visited, until all available nodes (i.e. power cables and electrical devices) have been visited and given the on/off signal.

Is this a sound way to implement the system?

seiken
Feb 7, 2005

hah ha ha

PiCroft posted:

Is this a sound way to implement the system?

Yes. You're basically doing a flood-fill, as I understand it. You probably want to implement it with a stack rather than actual recursion though, as you'll risk blowing the call stack otherwise (depending on what language you're using)

Since generators and devices are the only things that really matter, you could conceivably keep a graph structure around that stores which of these are connected to each other, and only update that when the cables are changed. But I'd be surprised if you actually needed that for good enough performance.

TJChap2840
Sep 24, 2009

the posted:

Pretty sure they do, yes. Just your standard collision box. Each sphere is (0.3,0.3,0.3) with a collider radius of 0.5. Huh... is the collider radius going to increase when I increase transform.localscale?


I have 100 red spheres named sphereRed and 100 blue spheres named sphereBlue. I don't see how it's feasible to give them all different names because ... well.. that seems like it would take awhile.

I think you are not understanding the people in this thread or you are leaving something key out. If you are checking red vs blue, you can give each prefab a tag of red or blue and then check for the tag on collision.

If you are just checking red vs red you can use the size of the transform of the objects that are colliding and make the smaller one disappear.

Does that capture every thing you are working on?

Edit: Seems I missed a page!

TJChap2840 fucked around with this message at 03:55 on Jul 26, 2013

Synthbuttrange
May 6, 2007

Just let the balls collide, they message a manager when they do, let the manager do all the decision making so it the destruction doesnt have the chance to run twice?

the
Jul 18, 2004

by Cowcaster
This doesn't seem to make any sense:

ERROR MESSAGE posted:

Assets/spherePhysicsBlue.js(19,41): BCE0051: Operator '>' cannot be used with a left hand side of type 'UnityEngine.Vector3' and a right hand side of type 'UnityEngine.Vector3'

Doing some research on the error, it looks like it pops up when you try to compare two different types (like a float and an integer). But as you can see, it's saying I'm comparing the same types. So... what the hell?

EDIT: Oh, wait, I bet it's because I'm trying to compare two vectors in terms of "size," and that doesn't make sense. It pops up when I try to compare the localscale. This must mean that's a vector. So how would I take the scalar of that vector in Unity?

the fucked around with this message at 05:57 on Jul 26, 2013

Bondematt
Jan 26, 2007

Not too stupid
Vector3.magnitude should be what you are looking for

the
Jul 18, 2004

by Cowcaster

Bondematt posted:

Vector3.magnitude should be what you are looking for

Thanks, I used transform.localscale.x, which I think has the same effect (because they're uniform spheres). It looks like... it just.. might.. be workin! :woop: Thanks to all of your for your help.

the
Jul 18, 2004

by Cowcaster
Again, thanks for your help.

I've been monitoring the scene as I play it, and the one strange bug I mentioned earlier is happening. It appears that occasionally one larger sphere will be destroyed by a smaller one, and I can't figure out why. Here is the code that is running on all spheres. I can't see what sort of condition would ever cause a larger sphere to be destroyed. Could it be Unity somehow glitching because it's not updating the positions fast enough? (Before you ask, this is the blue sphere code, which is the same as the red with the simple name change, both are experiencing the same issue).

JavaScript code:
#pragma strict


function Start () {
		rigidbody.velocity = Vector3(Random.Range(0,4),Random.Range(0,4),Random.Range(0,4));
		rigidbody.position = Vector3(Random.Range(-9,9),Random.Range(1,19),Random.Range(-9,9));

}

function Update () {
}

function OnCollisionEnter (col : Collision)
{
	//Check if you hit sphere of your color	
    if(col.gameObject.name == "sphereBlue")
	{
		//Check if you're larger than the other. If so, grow larger.
		if(transform.localScale.x > col.gameObject.transform.localScale.x)
		{
		transform.localScale += Vector3(.5,.5,.5);		
		}
		//Check to see if you're smaller than the other. If so, kill yourself.
		if(transform.localScale.x < col.gameObject.transform.localScale.x)
		{
		Destroy(gameObject);
		}
		//Otherwise do the other checks
		else
		{
			var thisSphere = GetInstanceID();
			var thatSphere = col.gameObject.GetInstanceID();
			//Compare instance ID
			//Check to see if yours is larger. If so, grow larger.
			if(thisSphere > thatSphere)
			{
				transform.localScale += Vector3(.1,.1,.1);
			}
			//Otherwise kill yourself
			else
			{
				Destroy(gameObject);
			}
		}
	}
}

seiken
Feb 7, 2005

hah ha ha

the posted:

Could it be Unity somehow glitching because it's not updating the positions fast enough? (Before you ask, this is the blue sphere code, which is the same as the red with the simple name change, both are experiencing the same issue).

You have an if which should be an else if

Chance
Apr 28, 2002

the posted:

I can't see what sort of condition would ever cause a larger sphere to be destroyed. Could it be Unity somehow glitching because it's not updating the positions fast enough? (Before you ask, this is the blue sphere code, which is the same as the red with the simple name change, both are experiencing the same issue).

Shouldn't the check if smaller and self destroy go before the grow script? It's kind of redundant to check the scale twice. Also I'm sure this has been covered before but why the compare by name instead of by tags? I'm a unity newbie myself but I always assumed that tags were faster than a direct string comparison for names.

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!

Chance posted:

Shouldn't the check if smaller and self destroy go before the grow script? It's kind of redundant to check the scale twice. Also I'm sure this has been covered before but why the compare by name instead of by tags? I'm a unity newbie myself but I always assumed that tags were faster than a direct string comparison for names.
Not faster enough to be worth doing - it's only doing the check when things collide, it's not like a multiple-calls-per-frame issue.

roomforthetuna fucked around with this message at 16:11 on Jul 26, 2013

Yodzilla
Apr 29, 2005

Now who looks even dumber?

Beef Witch
Gotta post my work. :getin: Another game jam game and this one is 1v1 on the same keyboard!

quote:

Player 1 Controls:
(move) A,D - move left/right
(firing) A,D - rotate turret counterclockwise/clockwise
(firing) W,S - increase/decrease power of shot
(firing) Space - shoot

Player 2 Controls:
(move) ←,→ - move left/right
(firing) ←,→ - rotate turret counterclockwise/clockwise
(firing) ↑,↓ - increase/decrease power of shot
(firing) Enter/Return - shoot



Rumble Dogs!

D1Sergo
May 5, 2006

Be sure to take a 15-minute break every hour.
Forgive the newbie question but it's a long thread and I haven't seen what I'm looking for:

I really liked Microsoft's XNA because I'm not a very strong programmer and I liked the way everything was set up to jump right into making something. However, I hear it's kind of dead or something. Does anyone have a recommendation for a library or environment to program in that can give me similar "jump right in" experience? C++ or C# or whatever is fine.

Kibbles n Shits
Apr 8, 2006

burgerpug.png


Fun Shoe

D1Sergo posted:

Forgive the newbie question but it's a long thread and I haven't seen what I'm looking for:

I really liked Microsoft's XNA because I'm not a very strong programmer and I liked the way everything was set up to jump right into making something. However, I hear it's kind of dead or something. Does anyone have a recommendation for a library or environment to program in that can give me similar "jump right in" experience? C++ or C# or whatever is fine.

You should look into Monogame. You can even use it with Visual Studio so it's really not that different at all. You'll need to compile your assets separately though. You can do this with an XNA project, or with this content compiler.

vvv yea that too.

Kibbles n Shits fucked around with this message at 20:44 on Jul 28, 2013

Vinterstum
Jul 30, 2003

D1Sergo posted:

Forgive the newbie question but it's a long thread and I haven't seen what I'm looking for:

I really liked Microsoft's XNA because I'm not a very strong programmer and I liked the way everything was set up to jump right into making something. However, I hear it's kind of dead or something. Does anyone have a recommendation for a library or environment to program in that can give me similar "jump right in" experience? C++ or C# or whatever is fine.

Unity.

poemdexter
Feb 18, 2005

Hooray Indie Games!

College Slice

And the Futile library if you want to do 2D games.

Synthbuttrange
May 6, 2007



My Unity/Playmaker/2d Toolkit/SA Gamedev VIII project. Keeping babies out of the furnace and sawmill lines is really hard when you start panicking.

Tres Burritos
Sep 3, 2009

Have any of you tried out Torque3d? I'd like to try making a game instead of just dicking with OpenGL, and I want to do it in linux. Or is that a lovely / unreasonable idea?

KoRMaK
Jul 31, 2012



Tres Burritos posted:

Have any of you tried out Torque3d? I'd like to try making a game instead of just dicking with OpenGL, and I want to do it in linux. Or is that a lovely / unreasonable idea?
Last I cheek on torque it was terrible. Unity seems like what torque wanted to be but actually works.

SneezeOfTheDecade
Feb 6, 2011

gettin' covid all
over your posts

SynthOrange posted:



My Unity/Playmaker/2d Toolkit/SA Gamedev VIII project. Keeping babies out of the furnace and sawmill lines is really hard when you start panicking.

Are... are the puppies supposed to go to the furnace? :smith:

Synthbuttrange
May 6, 2007

Besesoth posted:

Are... are the puppies supposed to go to the furnace? :smith:

Do you see anywhere else they can go? :ohdear:

TJChap2840
Sep 24, 2009

SynthOrange posted:

Do you see anywhere else they can go? :ohdear:

You sick man.

D1Sergo
May 5, 2006

Be sure to take a 15-minute break every hour.

SynthOrange posted:



My Unity/Playmaker/2d Toolkit/SA Gamedev VIII project. Keeping babies out of the furnace and sawmill lines is really hard when you start panicking.

Looks spiffy, I'll check it out. Thanks guys.

SneezeOfTheDecade
Feb 6, 2011

gettin' covid all
over your posts

SynthOrange posted:

Do you see anywhere else they can go? :ohdear:

A nice farm upstate, where they can chase rabbits all day? :(

Adbot
ADBOT LOVES YOU

Shalinor
Jun 10, 2002

Can I buy you a rootbeer?

Besesoth posted:

Are... are the puppies supposed to go to the furnace? :smith:
I'm gonna add a "Compassion" score category to SA GameDev, and I'm totes giving you like MINUS ONE BILLION for sending puppies into the furnace. :mad:

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