# Box2D Forums

 It is currently Wed May 22, 2013 5:05 pm

 All times are UTC - 8 hours [ DST ]

 Page 3 of 3 [ 25 posts ] Go to page Previous  1, 2, 3
 Print view Previous topic | Next topic
Author Message
 Post subject: Re: Flash jump'n'run -> The Adventures of TingerPosted: Mon Aug 18, 2008 11:33 am

Joined: Sat Jun 07, 2008 11:10 am
Posts: 65
A great game and a great article to go with it. Very informative. I hope you don't mind, but I added a link to your article to the 'List of useful articles' Wiki:

http://www.box2d.org/wiki/index.php?title=List_of_useful_articles

Top

 Post subject: Re: Flash jump'n'run -> The Adventures of TingerPosted: Tue Aug 19, 2008 5:03 am

Joined: Sat Aug 02, 2008 11:37 am
Posts: 7
@Maroxe

if you have the collission manifold, all you do is:
var normal:b2Vec2 = manifold.normal;
var angle:Number = ( Math.asin ( normal.x / normal.Length () ) / Math.PI * 180);

(Note: this is Actionscript 3 using box2d 1.4)

@Boris: thanks, yes it is a shame, perhaps in a future release of the game I'll try to fix this. I'm a bit short on time atm.

@Pault: No I don't mind at all. Thanks for linking.

Top

 Post subject: Re: Flash jump'n'run -> The Adventures of TingerPosted: Tue Aug 19, 2008 7:23 am

Joined: Thu Jul 17, 2008 11:24 am
Posts: 54
Code:
b2Vec2 n = point->normal;//normal vector
b2Vec2 v(0, 1);   //up vector
float cosAngle = (v.x*n.x+v.y*n.y) / (v.Length() * n.Length());
angle = acosf(cosAngle);

Top

 Post subject: Re: Flash jump'n'run -> The Adventures of TingerPosted: Tue Aug 19, 2008 7:43 am

Joined: Fri May 16, 2008 10:09 am
Posts: 337
Can't you just take the contact normal and extract the angle from it? The normal points from shape1 to shape2. Just do atan2(normal.y,normal.x).

For multiple contacts i suppose you can just average the angle (average the normals then take angle).

Top

 Post subject: Re: Flash jump'n'run -> The Adventures of TingerPosted: Wed Aug 20, 2008 4:09 pm

Joined: Thu Jul 17, 2008 11:24 am
Posts: 54
huesforalice wrote:
@Boris: I'd have to check the code again, but I'm pretty sure that I'm only setting the velocity. I also aply a counterforce to gravity as long as he is not moving and touching the ground, so that he doesn't slip down the slopes. About your bug report, the angle that tinger stands in is defined by the normalvector of his collission with ground. So if he stands on the edge of a collissionbox, he'll stand at an angle. I don't really consider this to be a serious bug, but thanks for pointing it out!

i had the same problem, the solution is to update the angle when collision persist, not when it's added(in C++ do it in ContactListener::Persist() not ContactListener::Add() )

Top

 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending
 Page 3 of 3 [ 25 posts ] Go to page Previous  1, 2, 3

 All times are UTC - 8 hours [ DST ]

#### Who is online

Users browsing this forum: No registered users and 2 guests

 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum

 Search for: