System Message

Secondary database maintenance is underway. Some features will be briefly unavailable.
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!

Orzo posted:

Why is it only 50% of the time that both spheres get destroyed? It seems like it should be 100%, if both spheres are blue, and Unity consistently messages both game objects during collision.
I'm guessing that calling Destroy on an object impacts at some point whether the message is sent to it or not. Calling 'Destroy' on oneself would be safe because you've already had the message, but destroying the partner object would cause difficulty. As for why it doesn't consistently cause the second message to not be delivered, that's hard to tell - I would guess some combination in the collision resolution code where if the collision is first detected from the perspective of the object with the higher ID it plays out one way, and if it's first detected from the perspective of the object with the lower ID it plays out the other way.

I'm having a hard time constructing code that would produce that result without it looking clearly intended to produce that result though. Maybe something like pseudocode
code:
foreach (Object as o) {
  if (o hasn't been destroyed) {
    foreach (o.QueuedMessage as m) {
      if (m is a collision) {
        if (m.otherobject.id < m.target.id) { 
//can't usefully put other half of collision message in the queue because we've already 
//gone past the other object in queue processing, so just do it now
          m.otherobject.handlecollision(m.swapobjectorder());
        } else {
          m.QueuedMessage.add(m.swapobjectorder());
        }
        o.handlecollision(m);
      }
    }
  }
}
Edit: alternatively, it might just be that our view of the code and results is missing the part where the "half the time" when things aren't destroyed is actually a collision between a blue sphere and something else.

Adbot
ADBOT LOVES YOU

the
Jul 18, 2004

by Cowcaster
Why can't I do something like:

1. If collide with object, check to see if it's sphereBlue
2. Check if you or the object you collided with is moving faster.
3. If you're moving faster, grow larger. If you're moving slower, destroy yourself.

I've been trying to code that myself, but I don't know how to check the velocity of the colliding gameobject.

I have something like this which is popping errors because it isn't correct:

JavaScript code:
function OnCollisionEnter (col : Collision)
{
    if(col.gameObject.name == "sphereBlue")
    {
		if(col.gameObject.velocity < rigidbody.velocity)
		{
		        Destroy(col.gameObject);
				transform.localScale += Vector3(.1,.1,.1);
		}
    }
}

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:

Why can't I do something like:
I addressed that in an edit earlier. First, you can't just do a "less than" on a velocity because it's not a scalar. You could do it on velocity.length (or whatever it is Unity uses for the magnitude of a vector), but then you'd still be occasionally getting a hosed result if the two objects have equal velocity. It is not a very good solution.

Edit: equal speed, I should say. Objects won't collide with equal velocity.

roomforthetuna fucked around with this message at 01:07 on Jul 3, 2013

the
Jul 18, 2004

by Cowcaster

roomforthetuna posted:

I addressed that in an edit earlier. First, you can't just do a "less than" on a velocity because it's not a scalar. You could do it on velocity.length (or whatever it is Unity uses for the magnitude of a vector), but then you'd still be occasionally getting a hosed result if the two objects have equal velocity. It is not a very good solution.

Hmm, okay, thanks.

KoRMaK
Jul 31, 2012



You should be able to cast the colliding object into the object type you think it is and then get its velocity.

seiken
Feb 7, 2005

hah ha ha

Suspicious Dish posted:

Yes, OpenGL calls take no time at all. You're not actually rendering in most cases, you're simply batching up commands to send to the GPU. There's really only one few place in modern GL where synchronization is required: The winsys's SwapBuffers equivalent (wglSwapBuffers/aglSwapBuffers/glxSwapBuffers/eglSwapBuffers).

Huh, well that makes sense but is kind of inconvenient for this I guess.

Fib posted:

It's possible that valgrind is just so slow that it's hiding the rendering overhead. Your own code is being valground but the GPU is running as fast as ever.

There are probably also tools that let you actually profile what's going on on the GPU. All I know of is PIX for DirectX but I found a blog post that suggests some OpenGL profiling tools for AMD and NVidia on Linux: http://blog.wolfire.com/2010/01/DirectX-vs-OpenGL-revisited

Thanks for the link. I'd intended to use regular CPU profiling to see which shaders were actually taking the time before actually profiling them with GPU things but I guess it's not possible. Maybe the GPU profilers can work on a bunch of shaders at once?

Incidentally, though a moot point now, I believe valgrind will compensate for its own slowdown by not sampling its own instrumentation code, thus for (synchronous) stuff the profiling won't be skewed even if some of your stuff is valground and some isn't.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
The whole point of the GPU is so that the CPU doesn't have to hang up or wait or calculate anything. The GPU is a graphics accelerator that takes the load off of the CPU. All that the CPU does in terms of the driver is build up commands to send to the GPU, and compile shaders.

In order to see what the GPU is doing, you need to use GPU profiling tools. There's apitrace, but that's not good for app development. Every vendor has its own set of profiling tools for its own OpenGL implementation.

Shalinor
Jun 10, 2002

Can I buy you a rootbeer?

Suspicious Dish posted:

In order to see what the GPU is doing, you need to use GPU profiling tools. There's apitrace, but that's not good for app development. Every vendor has its own set of profiling tools for its own OpenGL implementation.
If I remember correctly, the Intel GPA will actually work on just about any GPU you throw at it. You won't get the same degree of information, but it was still surprisingly versatile.

... but that was 3 years ago, so for all I know that's since changed.

seiken
Feb 7, 2005

hah ha ha

Suspicious Dish posted:

The whole point of the GPU is so that the CPU doesn't have to hang up or wait or calculate anything. The GPU is a graphics accelerator that takes the load off of the CPU. All that the CPU does in terms of the driver is build up commands to send to the GPU, and compile shaders.

In order to see what the GPU is doing, you need to use GPU profiling tools. There's apitrace, but that's not good for app development. Every vendor has its own set of profiling tools for its own OpenGL implementation.

The whole point of the GPU is to make certain stuff really fast and parallel. Obviously the way it works is fine and sane and good, but if GPU calls blocked it wouldn't be that much different in practice since you're going to have to wait for the final result at the end anyway like you said and you can always do your own threading

Kibbles n Shits
Apr 8, 2006

burgerpug.png


Fun Shoe
Well this is annoying. My monogame project in VS2010 suddenly won't debug. I press F5/click the debug button, and it just grays out briefly before returning to normal. Other projects still debug just fine. I made sure the program wasn't still running in the background and tried a reboot, but nothing seems to work.

superh
Oct 10, 2007

Touching every treasure

DarthJeebus posted:

Well this is annoying. My monogame project in VS2010 suddenly won't debug. I press F5/click the debug button, and it just grays out briefly before returning to normal. Other projects still debug just fine. I made sure the program wasn't still running in the background and tried a reboot, but nothing seems to work.

I'm not super familiar with VS 2010 or monogame but are there any errors that are preventing the game from compiling? Or any messages spit out into a build log?

Kibbles n Shits
Apr 8, 2006

burgerpug.png


Fun Shoe

superh posted:

I'm not super familiar with VS 2010 or monogame but are there any errors that are preventing the game from compiling? Or any messages spit out into a build log?

No errors at all, and there doesn't appear to be any sort of log in the build path. I also tried rolling my project back to before this started happening and still no luck. (Note: no significant changes were made anyways, just some new code in an already existing class).

Edit: Well whatever the problem was, it appears to have corrected itself.

Kibbles n Shits fucked around with this message at 02:37 on Jul 5, 2013

Yodzilla
Apr 29, 2005

Now who looks even dumber?

Beef Witch
Was the answer to restart Visual Studio? :haw:

Kibbles n Shits
Apr 8, 2006

burgerpug.png


Fun Shoe

Yodzilla posted:

Was the answer to restart Visual Studio? :haw:

Not unless I had to restart it 5 or so times for it to work.

Oddly, disabling the "visual studio hosting process" let me debug again, but I rechecked it because I didn't know what I was doing. Then lo and behold, it started working again for reasons. But not right away. Pretty sure it's just trolling me.

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!
I have had the solution to that kind of a problem be "reboot" before - though on a later repetition I found out the actual problem was an invisible stalled debug process (not stalled in my code, but stalled before it had even actually started the program - stalled waiting for a connection to debug or something); killing that in task manager was a quicker solution.

aerique
Jul 16, 2008
What would be the thread to talk about game design / mechanics?

Lazerbeam
Feb 4, 2011

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

poemdexter
Feb 18, 2005

Hooray Indie Games!

College Slice
Unity question time. I have a player object with a Rigidbody and Box Collider. I want to have enemies that can walk on the ground, fall off ledges, and bump into the player. I also want the player to be able to pass through enemies during a small window of invulnerability after getting hit. I also don't want player pushing enemies or enemies pushing players.

I've tried a ton of combinations of Box Colliders with Is Trigger true and false and Rigidbodies Components on the enemy but I can't seem to get everything I want at once. Anyone know how I can accomplish the above? If you need a more clear picture, think Rogue Legacy enemies that walk on the ground but you can walk through them once hit.

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!
Make enemies a layer, turn off collisions between player layer and enemy layer while invulnerable.

poemdexter
Feb 18, 2005

Hooray Indie Games!

College Slice

roomforthetuna posted:

Make enemies a layer, turn off collisions between player layer and enemy layer while invulnerable.

This works perfectly but now I have a follow up question. I'm checking for both OnCollisionEnter and OnCollisionStay so that if you are inside the enemy when you come of invulnerability, I want to you get hit again. However, OnCollisionStay isn't triggering. I can only get OnCollisionEnter to trigger or I can only get OnCollisionStay to trigger IF you move while inside the enemy. That is, if you are inside the enemy and neither of you are moving, OnCollisionStay will not trigger. Is there a solution to this?

EDIT: The solution was to call Rigidbody.WakeUp() after invulnerability wears off.

poemdexter fucked around with this message at 03:57 on Jul 6, 2013

Workaday Wizard
Oct 23, 2009

by Pragmatica
Unity 2d collision question:
I am making a simple 2d shmup with orthographic projection camera and textured quads. In the game the z axis is only for layering.

I want to do collision checking by comparing 2d bounding boxes in the x-y plane. In other words simple 2d collision.

How can I do that without having to re-implement the game object cycle (update, collision checking, physics, etc.) using some sort of game manager object?

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!

Shinku ABOOKEN posted:

Unity 2d collision question:
I am making a simple 2d shmup with orthographic projection camera and textured quads. In the game the z axis is only for layering.

I want to do collision checking by comparing 2d bounding boxes in the x-y plane. In other words simple 2d collision.

How can I do that without having to re-implement the game object cycle (update, collision checking, physics, etc.) using some sort of game manager object?
You could just attach z-tall 3D collision objects to each quad, for the collision detection. You can either lock rotation and z movement on the objects, or use kinematic objects for collision detection only and implement your own movement physics (which for a shmup probably makes more sense - not many shmups want things pushing each other around).

Or you could use a Unity Box2D or other 2D physics port, but that would probably require pro for a plugin and it's not like the slight wastefulness of using 3D collision detection is going to make a simple 2D shmup too slow.

xzzy
Mar 5, 2009

So I've kind of hit a brick wall.. anyone got any ideas for making an articulated hand as in Surgeon Simulator? I'm guessing in that game they used an IK rig, but it's a unity pro feature so I have to come up with something else.

I tried faking it using rigidbodies and hinges for a couple hours and wasn't really happy with the results I was getting.

Really hoping the best solution isn't to animate in Blender and export every possible hand pose.

poemdexter
Feb 18, 2005

Hooray Indie Games!

College Slice
Anyone have experience doing networking in Unity? The built in stuff seems easy to use and there's several 3rd party options. I'm wondering if I should just skip all of that and unearth my lidgren client/server and just slap it in Unity. I'm also wondering how having the physics in Unity be non deterministic is going to affect multiplayer.

SuicideSnowman
Jul 26, 2003

poemdexter posted:

Anyone have experience doing networking in Unity? The built in stuff seems easy to use and there's several 3rd party options. I'm wondering if I should just skip all of that and unearth my lidgren client/server and just slap it in Unity. I'm also wondering how having the physics in Unity be non deterministic is going to affect multiplayer.

I did some basic networking with uLink. The nice thing is it runs in a Unity instance so you can incorporate Unity physics into it. The bad this is it runs in a Unity instance and unless you have pro, you can't run in headless mode.

The built in networking is a stripped down version of RakNet AFAIK but I've read it's not all that optimized.

It all depends on how complex of a networking infrastructure you're looking at. If it's just a simple small player count game, the built in would probably be just fine. If you're wanting to go with something more complex that allows a lot more connections, one of the 3rd party options would probably be optimal.

Yodzilla
Apr 29, 2005

Now who looks even dumber?

Beef Witch
Is there any way to use position tweening with GoKit in Futile? Since Futile objects don't have transforms (that I know of) I'm not sure how it'd be possible and it just outputs an error if you attempt.


e: oh you can just pass "x" and "y" into floatProp :downs:

Yodzilla fucked around with this message at 02:58 on Jul 8, 2013

poemdexter
Feb 18, 2005

Hooray Indie Games!

College Slice

SuicideSnowman posted:

I did some basic networking with uLink. The nice thing is it runs in a Unity instance so you can incorporate Unity physics into it. The bad this is it runs in a Unity instance and unless you have pro, you can't run in headless mode.

The built in networking is a stripped down version of RakNet AFAIK but I've read it's not all that optimized.

It all depends on how complex of a networking infrastructure you're looking at. If it's just a simple small player count game, the built in would probably be just fine. If you're wanting to go with something more complex that allows a lot more connections, one of the 3rd party options would probably be optimal.

I'm thinking a coop game so no more than maybe 4 people at once. I might give it a shot. Thanks.

Orzo
Sep 3, 2004

IT! IT is confusing! Say your goddamn pronouns!
I ran into something funny tonight with Visual Studio. I have music playing with FMOD and when a breakpoint hits in debug mode, the music stops. But when I mouse over something to inspect its value, you hear the music for a split second, presumably because the debugger is waking up the thread in order to evaluate things.

Yodzilla
Apr 29, 2005

Now who looks even dumber?

Beef Witch
Is there a good place I should start with learning physics in Unity? I'm trying to understand how they and Futile mesh together and I'm using Matt Rix's game jam project as a reference but I'm sure that I just don't get all of the concepts yet.

I guess what I'd like to do is get a simple vehicle working. I guess in 2D land that'd be a box collider body, two sphere colliders for wheels and then somehow connected with springs for the shocks? Would it even be possible to have the rotation of the wheels actually power the vehicle as opposed to faking it and just applying force to the whole object?

poemdexter
Feb 18, 2005

Hooray Indie Games!

College Slice

Yodzilla posted:

Is there a good place I should start with learning physics in Unity? I'm trying to understand how they and Futile mesh together and I'm using Matt Rix's game jam project as a reference but I'm sure that I just don't get all of the concepts yet.

I guess what I'd like to do is get a simple vehicle working. I guess in 2D land that'd be a box collider body, two sphere colliders for wheels and then somehow connected with springs for the shocks? Would it even be possible to have the rotation of the wheels actually power the vehicle as opposed to faking it and just applying force to the whole object?

I'm still pretty new to the pure Unity side, but I think it's the rigidbody component that allows things to physically exist in the game world. The colliders are just there for collisions and triggers.

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:

I'm still pretty new to the pure Unity side, but I think it's the rigidbody component that allows things to physically exist in the game world. The colliders are just there for collisions and triggers.
The colliders determine the shape, the rigidbody just holds the velocities etc.

Shalinor
Jun 10, 2002

Can I buy you a rootbeer?

roomforthetuna posted:

The colliders determine the shape, the rigidbody just holds the velocities etc.
The rigidbodies are also what keep an object from collapsing colliders into one object, as a matter of interest.

Example: say you wanted 3 hit volumes childed to your actor. So you make 3 child objects, each with its own Collider, marked as triggers. If each of those bodies doesn't also have a rigidbody, those geoms get ripped off of those child objects and stuffed onto your main parent object.

Given that OnTriggerEnter et al don't make it possible to tell what trigger was actually hit, that's real bad. So, you put a rigid body on each of the children, mark it as kinematic so that it moves along with the parent, and then you get the events you'd expect.

Verus
Jun 3, 2011

AUT INVENIAM VIAM AUT FACIAM
This is probably way too specific a question, but does anyone know a good, efficient way to draw a minimap/map overview in SDL2 (for a simple, tile-based game)? I'd like it to look basically like this for the minimap:

and this for the larger map:


So far I've tried three different things: first, I just did the very naive thing and rendered a shitload of 4x4 coloured, square textures--this has actually been the fastest method I've tried, and it works great for the minimap but it's absurdly slow when trying to draw an entire screenful of map this way. Next, I tried using SDL_RenderDrawPoints() to just directly render coloured pixels, but it was hilariously slow.

Finally, I tried creating an SDL_Surface and filling in the pixel data, then creating a texture from that so that I'd only be making one render call. This seems like it should be a lot faster, but when I tried it the constant calls to CreateTextureFromSurface() and DestroyTexture() killed performance.

(I could just draw the large map once and not allow the player to do anything that could change its appearance while it's up, but I really don't want to force the game to pause just because the map's pulled up.)

aerique
Jul 16, 2008

Verus posted:

Next, I tried using SDL_RenderDrawPoints() to just directly render coloured pixels, but it was hilariously slow.

Did you make sure the surface was locked when doing this? I always forgot to do that and then wondered why drawing a couple of pixels was so slow.

seiken
Feb 7, 2005

hah ha ha

Verus posted:

Finally, I tried creating an SDL_Surface and filling in the pixel data, then creating a texture from that so that I'd only be making one render call. This seems like it should be a lot faster, but when I tried it the constant calls to CreateTextureFromSurface() and DestroyTexture() killed performance.

Probably the easiest thing would be to use something like this method, but don't destroy and recreate the texture the whole time. Keep the texture around and use SDL_UpdateTexture to change the pixel data. Since that function takes a rect, ideally you can update only the portions of the texture that have actually changed since the last frame.

Edit: I'm not actually familiar with SDL and its functions, it might be faster to render over the changed bits of the texture rather than using SDL_UpdateTexture if that's possible.

seiken fucked around with this message at 19:28 on Jul 8, 2013

Yodzilla
Apr 29, 2005

Now who looks even dumber?

Beef Witch
So I finally started messing with GoKit which really loving owns but that got me thinking about timers and such in general. With GoKit I can create tweens, chain them, pause them, loop them, whatever and have them issue a callback on completion. The pausing is important obviously because I want to be able to pause gameplay tweens without pausing all tweens because I'll still need them for the menu overlay.

Now as far as timers go, I know Unity has the Invoke command where you can specify a method to call after X seconds but this just seems really bad and sloppy as there's no way to cancel or suspend an Invoke besides settings Time.timeScale to zero which is a bad idea for a number of reasons. So for actions that I want an easily pause-able timer for does it make sense to just have GoKit "tween" something out of sight just for the callback? That way I can use the framework as a really nice controllable timer as well as for its visual tweening abilities,

poemdexter
Feb 18, 2005

Hooray Indie Games!

College Slice

Yodzilla posted:

So I finally started messing with GoKit which really loving owns but that got me thinking about timers and such in general. With GoKit I can create tweens, chain them, pause them, loop them, whatever and have them issue a callback on completion. The pausing is important obviously because I want to be able to pause gameplay tweens without pausing all tweens because I'll still need them for the menu overlay.

Now as far as timers go, I know Unity has the Invoke command where you can specify a method to call after X seconds but this just seems really bad and sloppy as there's no way to cancel or suspend an Invoke besides settings Time.timeScale to zero which is a bad idea for a number of reasons. So for actions that I want an easily pause-able timer for does it make sense to just have GoKit "tween" something out of sight just for the callback? That way I can use the framework as a really nice controllable timer as well as for its visual tweening abilities,

http://docs.unity3d.com/Documentation/ScriptReference/index.Coroutines_26_Yield.html

Unity has WaitForSeconds(float seconds) but you need to throw it in a coroutine. I hope this answers your question somewhat.

Yodzilla
Apr 29, 2005

Now who looks even dumber?

Beef Witch
I'm vaguely familiar with coroutines but haven't used them. I guess in that case if you did set something like that up you'd have to control the pausing yourself through some global variable, no?

poemdexter
Feb 18, 2005

Hooray Indie Games!

College Slice

Yodzilla posted:

I'm vaguely familiar with coroutines but haven't used them. I guess in that case if you did set something like that up you'd have to control the pausing yourself through some global variable, no?

Well I think this would be more if you knew exactly how long and when to pause outside of doing it within the tween chain. Are you talking about sorta pausing tweening to have maybe some UI menu come up. Like a global pause button?

Adbot
ADBOT LOVES YOU

Yodzilla
Apr 29, 2005

Now who looks even dumber?

Beef Witch
Yeah basically what I'm doing now is when I create my tweens I'm grouping them into lists of game tweens and menu tweens. While in gameplay when you click the pause button to open the menu I'm pausing all game tweens but allowing the menu tweens to keep running. That way poo poo doesn't keep sliding around in the game world while you're paused.

I was thinking that combined with the completion callbacks could make a really easy to use and easily to manipulate set of timers instead of relying on coroutines.

I'm more just putting the idea out there instead of asking a question. I guess I'm more wondering if it's a good idea or if there are any downsides.

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