GMLscripts.com

Discuss and collaborate on GML scripts
Invert

You are not logged in.

#1 2010-09-16 19:07:30

Marchal_Mig12
Member
Registered: 2009-05-21
Posts: 75

Basic Vector Physics Need Help :)

Hi everyone for anyone interested into vector physics, here's something I started up to hopefully become an engine much faster than the one I already have.

So first of all, here it is: www.edm-games.com/PhysicsTest.gmk (GM8) and www.edm-games.com/PhysicsTest2.gmk (GM7)

The problem is when the ball hits the last line, it would go down and slide through the floor. One solution could be to use collision circle instead of collision line to determine if the player is colliding with a line but I do not know how to calculate it and if the ball would be moving at higher speed there would be chances that it passes through the floor. Using collision line, it prevents the ball from passing through the floor even at high speed.

Hopefully, someone here will be able to solve the problem smile.

Good luck!

Miguel

Offline

#2 2010-09-17 01:28:53

icuurd12b42
Member
Registered: 2008-12-11
Posts: 303

Re: Basic Vector Physics Need Help :)

I think the problem is that you apply the physics on a line by line basis as opposed to calculating the total resulting directional vector for all the intersecting lines. the result is interference...
When the object is wedge at the v part of the second and last line, first you move down the slope of the second line then down the slope of the last line. Where as the vector should be the combination of the 2 lines intersecting the object.

Offline

#3 2010-09-17 04:54:53

xot
Administrator
Registered: 2007-08-18
Posts: 1,239

Re: Basic Vector Physics Need Help :)

I just happened to stumble across this GMC topic today. It might give you some ideas.

http://gmc.yoyogames.com/index.php?showtopic=446152


Abusing forum power since 1986.

Offline

#4 2010-09-17 07:31:49

Marchal_Mig12
Member
Registered: 2009-05-21
Posts: 75

Re: Basic Vector Physics Need Help :)

icuurd12b42 wrote:

I think the problem is that you apply the physics on a line by line basis as opposed to calculating the total resulting directional vector for all the intersecting lines. the result is interference...
When the object is wedge at the v part of the second and last line, first you move down the slope of the second line then down the slope of the last line. Where as the vector should be the combination of the 2 lines intersecting the object.

I understand what you're saying but I do not know how to do that sad.


Thanks Xot, actually, here's a new engine using his method: www.edm-games.com/PhysicsTest.gmk (GM8) and www.edm-games.com/PhysicsTest2.gmk (GM7)

The only problem so far is that  at high speed, if the ball hits the wall, it might jump on the wrong side of the line. I think it is caused by I wrong  calculation in the script that calculates the distance between the center of the ball and the line. So if the ball's mid point passes the line it will jump on the wrong side. From my understand, it should happen 1 out of 2 times.

Any ideas?

Again,

Thank you,

Miguel

Offline

#5 2010-09-17 14:21:38

xot
Administrator
Registered: 2007-08-18
Posts: 1,239

Re: Basic Vector Physics Need Help :)

The first idea is to consider that logically the side of the line the ball should be on after the response is the same side it was on before the collision.

The second idea is to give your lines a sidedness (treat them as having an "in" side and an "out" side), and you should be able to always force the ball to move in the "out" direction. The "out" direction of a line could be the vector {(y1-y2),(x2-x1)}.


Abusing forum power since 1986.

Offline

#6 2010-09-17 16:52:42

Marchal_Mig12
Member
Registered: 2009-05-21
Posts: 75

Re: Basic Vector Physics Need Help :)

xot wrote:

The first idea is to consider that logically the side of the line the ball should be on after the response is the same side it was on before the collision.

The second idea is to give your lines a sidedness (treat them as having an "in" side and an "out" side), and you should be able to always force the ball to move in the "out" direction. The "out" direction of a line could be the vector {(y1-y2),(x2-x1)}.

So you're saying that each line should be either forcing one side or the other?

EDIT: All in All, since I am not very good with vectors and everything, what I am struggling with is moving the ball out of the line whenever there is a collision. Can you help on that?

Last edited by Marchal_Mig12 (2010-09-17 17:05:35)

Offline

#7 2010-09-19 18:07:31

xot
Administrator
Registered: 2007-08-18
Posts: 1,239

Re: Basic Vector Physics Need Help :)

I don't know how much I can really help. Collision response is something I struggled with for one my own projects. In the end, between performance problems and the difficulty of the topic, I decided it was almost pointless to try to reinvent the physics wheel.

What are you plans for this? Is there a reason you don't want to use one of the existing Game Maker physics systems? I can certainly understand the desire to solve the problem yourself, but if this is for a game you are trying to make, and the physics is holding you back, I wouldn't dismiss any available solutions.


Abusing forum power since 1986.

Offline

#8 2010-09-19 18:45:39

Marchal_Mig12
Member
Registered: 2009-05-21
Posts: 75

Re: Basic Vector Physics Need Help :)

xot wrote:

I don't know how much I can really help. Collision response is something I struggled with for one my own projects. In the end, between performance problems and the difficulty of the topic, I decided it was almost pointless to try to reinvent the physics wheel.

What are you plans for this? Is there a reason you don't want to use one of the existing Game Maker physics systems? I can certainly understand the desire to solve the problem yourself, but if this is for a game you are trying to make, and the physics is holding you back, I wouldn't dismiss any available solutions.

I figured out a way to make it work however I am not sure how well it works. tongue

Offline

Board footer

Powered by FluxBB