Home Tutorials Forums Articles Blogs Movies Library Employment Press

 ActionScript.org Forums [AS3] walking on slope with real gravity
 Register FAQ Members List Social Groups Calendar Search Today's Posts Mark Forums Read

 11-07-2011, 02:33 AM #1 scarce Senior Member   Join Date: Dec 2007 Location: Millersburg, PA Posts: 266 [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
11-08-2011, 06:28 PM   #2
scarce
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
 Eraser Man.zip (272.7 KB, 45 views)

 Thread Tools Display Modes Rate This Thread Linear Mode Rate This Thread: 5 : Excellent 4 : Good 3 : Average 2 : Bad 1 : Terrible

 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 Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home ActionScript Forums Group     ActionScript 3.0     ActionScript 2.0     ActionScript 1.0 (and below)     Simple Stuff (Newbies) Flash General Questions     Flash 10 General Questions     Flash 9 General Questions     Flash 8 General Questions     Other Flash General Questions Flex     Flex 2, 3 & 4     Flex 1 Extensions and Plugins     Components     JSFL - Extending Flash Desktop, Mobile and non-browser Environments     AIR (Apollo)     FlashLite / Portable Devices Development     Projectors and CDs Supporting Technologies     HTML and JavaScript     haXe     Server-Side Scripting     Flash Remoting     Flash Media Server General     Best Practices     Gaming and Game Development     Animation and Effects     Flashants Support Forum Community Boards     General Chat     Just for Kicks Challenges     Detention Flash In Action     Site Check     Cool Sites     Widgets Decommissioned     Projects and Positions CMS Forums     Announcements Board     Content Postings / Updates     Product Review Requests     CMS Technical Questions     Process Questions     Collaboration & Suggested Articles

All times are GMT. The time now is 08:37 AM.

///