PDA

View Full Version : physics based halfpipe question



slideth3
September 5th, 2006, 08:58 AM
hey everyone,

been making a physics based halfpipe

http://www.kitegallery.net/misc/Slideth/Sam/halfpipe+real+physics.swf.html

anyway the problem is that one of the wheels reacts to the halfpipe perfectly but the one that is connected to it doesn't, because of the way i have made them stick together with a set distance.

Is there anyway ik style where i could make the both stick to each other and react to the outside perfectly.

along the lines of those motorbike games..... eg at teagames



dx = this._x - _root.ball2._x
dy = this._y - _root.ball2._y
d = 50
a = Math.atan2(dy, dx);
_root.ball2._x = this._x - Math.cos(a)*d
_root.ball2._y = this._y - Math.sin(a)*d


see all i'm doing at the moment is attaching the second ball to the first and not the other way arround,

is there any way of doing both so to speak! lol

thaaaanks

INSANE SYTH
September 7th, 2006, 06:41 AM
You could perhaps test to see which ball is in contact with the half pipe and have the other follow that one, if they are both in contact or niether then whichever is moving faster, i.e. keep track of how far it has traveled in the last 3 or so frames and average it out.
Might work, failing that have the balls move by themselves but if the link gets stretched too much they are pulled towards eachother.
Hope i was helpful.