generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Collision detection overlapping causes "pushing"

Previous Thread :: Next Thread 
pighead10 is not online. pighead10
Joined: 03 May 2009
Total Posts: 10341
23 Sep 2012 07:15 AM
I'm detecting collisions in GUIs. If object a is moving towards object b, then the collision between them will be detected when object a is very slightly overlapping on object b. I have the translation vector needed, but if I move one of the objects by the vector they will always be able to "push" other objects by constantly moving into them and forcing them to offset by a certain amount each time.

I can only think of hacky or inefficient solutions to this problem. Is there a way to solve it?
Report Abuse
Candymaniac is not online. Candymaniac
Joined: 08 Oct 2009
Total Posts: 8985
23 Sep 2012 07:30 AM
What's the specific cause of them pushing each other?

☜▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬☞
Report Abuse
pighead10 is not online. pighead10
Joined: 03 May 2009
Total Posts: 10341
23 Sep 2012 07:32 AM
When an object collides it will be slightly overlapping. Offsetting the object to make it not overlap causes the pushing.
Report Abuse
Candymaniac is not online. Candymaniac
Joined: 08 Oct 2009
Total Posts: 8985
23 Sep 2012 07:46 AM
Are you offsetting the object that got hit or the object that is the one colliding?

☜▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬☞
Report Abuse
pighead10 is not online. pighead10
Joined: 03 May 2009
Total Posts: 10341
23 Sep 2012 07:51 AM
There's no way of telling - it's not an object was hit, it's an object collided with something else.
Report Abuse
ArceusInator is not online. ArceusInator
Joined: 10 Oct 2009
Total Posts: 30553
23 Sep 2012 08:02 AM
I think that's what hit means.
Report Abuse
NXTBoy is not online. NXTBoy
Joined: 25 Aug 2008
Total Posts: 4533
23 Sep 2012 08:33 AM
Move both a and b?
Report Abuse
Candymaniac is not online. Candymaniac
Joined: 08 Oct 2009
Total Posts: 8985
23 Sep 2012 08:41 AM
Can't you check to see which object is the one that hit b by checking if it was moving or not?

I think you're offsetting both...

☜▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬☞
Report Abuse
Davidii is not online. Davidii
Joined: 17 Jul 2008
Total Posts: 1282
23 Sep 2012 08:46 AM
If they each have a vector2 representing velocity, give each a mass (or base the mass on the size of the gui). Go learn some physics equations for momentum and transfer of momentum, then implement those. Ta da...
Report Abuse
pighead10 is not online. pighead10
Joined: 03 May 2009
Total Posts: 10341
23 Sep 2012 09:23 AM
"Move both a and b?"

If I moved both by half the amount then I'd run into all kinds of issues wif I used more than 2 blocks. For example, a long chain of blocks and I am overlapping one on the end would mean the entire chain moved.

"Can't you check to see which object is the one that hit b by checking if it was moving or not?"

And if they're both moving? There's no way of checking which one hit another.

"If they each have a vector2 representing velocity, give each a mass (or base the mass on the size of the gui). Go learn some physics equations for momentum and transfer of momentum, then implement those. Ta da..."

There already is - this for an already partially functional GUI physics engine. It doesn't exactly solve the issue... =p
Report Abuse
pighead10 is not online. pighead10
Joined: 03 May 2009
Total Posts: 10341
23 Sep 2012 09:25 AM
As I said, there are quite a few hacky fixes but none of which work perfectly all the time. Unless someone knows a 'proper' solution to the problem then I think ignoring it until the rest of the physics are complete, then trying to find a hacky solution that works with that would be best.
Report Abuse
trappingnoobs is not online. trappingnoobs
Joined: 05 Oct 2008
Total Posts: 19100
23 Sep 2012 09:46 AM
hard to understand what you mean

do you want it so you can have walls that people can't move?
Report Abuse
pighead10 is not online. pighead10
Joined: 03 May 2009
Total Posts: 10341
23 Sep 2012 09:49 AM
mumble

No. When two objects collide, one is inevitably slightly overlapping the other. When I offset that so it isn't overlapping the other, they get moved so that it appears one is pushing the other.
Report Abuse
trappingnoobs is not online. trappingnoobs
Joined: 05 Oct 2008
Total Posts: 19100
23 Sep 2012 09:51 AM
just use velocity to check which is pushing into which and push it back
Report Abuse
Candymaniac is not online. Candymaniac
Joined: 08 Oct 2009
Total Posts: 8985
23 Sep 2012 09:54 AM
"And if they're both moving? There's no way of checking which one hit another."
Well then just simulate and assume that both objects hit each other and simulate a bounce-back feature.

☜▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬☞
Report Abuse
stravant is not online. stravant
Forum Moderator
Joined: 22 Oct 2007
Total Posts: 2893
23 Sep 2012 12:40 PM
You can find whole books on this problem.

Google "stable stacking collisions" to find lots of discussions about this topic.
Report Abuse
pighead10 is not online. pighead10
Joined: 03 May 2009
Total Posts: 10341
23 Sep 2012 01:10 PM
"You can find whole books on this problem." probably means I can't solve it. Still, it's worth a try.
Report Abuse
stravant is not online. stravant
Forum Moderator
Joined: 22 Oct 2007
Total Posts: 2893
23 Sep 2012 01:20 PM
Well, you totally can solve it, but it would be way faster to look at how existing implementations do it than try to invent it yourself. The general idea is:

- Find what's colliding
- Generate a system of constraints for the colliding surfaces
- Iteratively solve that system to the desired precision
- Apply that solution as offsets + impulses to the colliding objects

Where the "system" will usually be a giant matrix of mathematical equations describing both the relationships between vertices colliding with faces of objects, and other constraints such as joints between objects.
Report Abuse
nate890 is not online. nate890
Joined: 22 Nov 2008
Total Posts: 21686
23 Sep 2012 01:24 PM
http://www.roblox.com/Bouncer-A-GUI-Physics-Game-place?id=67312117

like that?
Report Abuse
pighead10 is not online. pighead10
Joined: 03 May 2009
Total Posts: 10341
23 Sep 2012 01:45 PM
@nate

Where accuracy doesn't matter like in that situation it's fine, I can easily do that with my physics engine, but in specific situations involving more complex collisions it can become an issue.
Report Abuse
aboy5643 is not online. aboy5643
Joined: 08 Oct 2010
Total Posts: 5458
23 Sep 2012 07:05 PM
I'm not fully wrapping my head around your issue, but if I do understand it ever, I can almost assuredly solve it. I've done extensive work on 2D physics in and out of ROBLOX
Report Abuse
stravant is not online. stravant
Forum Moderator
Joined: 22 Oct 2007
Total Posts: 2893
23 Sep 2012 07:26 PM
@aboy
He's trying to have stable stacking, and his algorithm is a naive one of just "push colliding bodies apart", so it obviously isn't working.
Report Abuse
sirsavary is not online. sirsavary
Joined: 27 May 2008
Total Posts: 1222
23 Sep 2012 07:32 PM
You're going to have to find what is colliding with what, and then push that object back and only it back. This reminds me of the code I wrote to handle perfect GUI collisions, Really sad that I lost it.

Join the Tamerac RPG Beta Group for exclusive updates!
Report Abuse
stravant is not online. stravant
Forum Moderator
Joined: 22 Oct 2007
Total Posts: 2893
23 Sep 2012 07:47 PM
"You're going to have to find what is colliding with what, and then push that object back and only it back."

That won't actually work for stable stacking, since you've only changed the problem from "how much to push" to "who gets to push", which is just as difficult a problem where both objects are free.
Report Abuse
sirsavary is not online. sirsavary
Joined: 27 May 2008
Total Posts: 1222
23 Sep 2012 08:00 PM
Ahh, didn't think of that. I never spent too much time in 2D, just kinda hopped the fence right into the realm of 3D.

Join the Tamerac RPG Beta Group for exclusive updates!
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image