Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 11-07-2011, 02:33 AM   #1
Senior Member
Join Date: Dec 2007
Location: Millersburg, PA
Posts: 266
Exclamation [AS3] walking on slope with real gravity

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.

ActionScript Code:
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,true))                 {                     eraserMan.y +=  velocity;                                     }                 while (! theGround.hitTestPoint(eraserMan.x,eraserMan.y,true))                 {                     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
scarce is offline   Reply With Quote
Old 11-08-2011, 06:28 PM   #2
Senior Member
Join Date: Dec 2007
Location: Millersburg, PA
Posts: 266

I got it now, I'm posting a zip with the fla and class files...it seems jumpy though, any ideas on smoothing it out?
Attached Files
File Type: zip Eraser Man.zip (272.7 KB, 45 views)
scarce is offline   Reply With Quote

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT. The time now is 04:31 PM.

Follow actionscriptorg on Twitter


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.