scarce

11-07-2011, 02:33 AM

ok, well I scratched my old physics on the game and decided to go based on real physics...I used an actualy gravity algorithum based on mass, distance, yada yada...I'm still having a problem with walking on a slope, making the character go up and down basically.

function charDist(event:Event):void

{

gPull = gravity * eraserMass / dist * dist;

getDist(eraserMan.x, eraserMan.y, theGround.x, theGround.y);

trace(touchDown);

}

function getDist(x1:Number, y1:Number, x2:Number, y2:Number):Number

{

dx = x1 - x2;

dy = y1 - y2;

dist = Math.sqrt(dx * dx + dy * dy);

return dist;

}

function gravity(event:Event):void

{

velocity -= gPull;

while (theGround.hitTestPoint(eraserMan.x,eraserMan.y,tr ue))

{

eraserMan.y += velocity;

}

while (! theGround.hitTestPoint(eraserMan.x,eraserMan.y,tru e))

{

eraserMan.y -= velocity;

}

}

the gravity function is where the issue is...the character falls faster and slower based on weight and distance...thats all great. But once I hit the ground, he stays linear...help please :D

function charDist(event:Event):void

{

gPull = gravity * eraserMass / dist * dist;

getDist(eraserMan.x, eraserMan.y, theGround.x, theGround.y);

trace(touchDown);

}

function getDist(x1:Number, y1:Number, x2:Number, y2:Number):Number

{

dx = x1 - x2;

dy = y1 - y2;

dist = Math.sqrt(dx * dx + dy * dy);

return dist;

}

function gravity(event:Event):void

{

velocity -= gPull;

while (theGround.hitTestPoint(eraserMan.x,eraserMan.y,tr ue))

{

eraserMan.y += velocity;

}

while (! theGround.hitTestPoint(eraserMan.x,eraserMan.y,tru e))

{

eraserMan.y -= velocity;

}

}

the gravity function is where the issue is...the character falls faster and slower based on weight and distance...thats all great. But once I hit the ground, he stays linear...help please :D