Box2D Forums

It is currently Tue May 21, 2013 4:40 am

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Wed Jan 12, 2011 3:19 am 
Offline

Joined: Wed Jan 12, 2011 3:16 am
Posts: 6
Hi,

I'm fairly new to Box2d, I've managed to make a game where objects spawn at the top of the screen, they fall and you have to catch them in a basket.

I want to measure the force of the impact (different objects have different mass and, if my understanding is correct, should hit with different forces?)

Code:
   void PostSolve(b2Contact* contact, const b2ContactImpulse* impulse)
   
   {
      NSLog(@"Normal Impulse X %f", impulse->normalImpulses);
      NSLog(@"Normal Impulse Y %f", impulse->normalImpulses);
   
      NSLog(@"Tangent Impulse X %f", impulse->tangentImpulses);
      NSLog(@"Tangent Impulse Y %f", impulse->tangentImpulses);
   }


This is the code I am using to attempt to log out some kind of data, but it seems to give me the same reading for every single collision. I'm assuming i'm doing something incorrectly. Could someone give me a little direction?.

Thank you.


Top
 Profile  
 
PostPosted: Wed Jan 12, 2011 4:27 am 
Offline

Joined: Wed Jan 12, 2011 3:16 am
Posts: 6
Worked it out, Objective-C is my first coding language, so i'm not used to calling objects out of structs.

Code:
      NSLog(@"Normal Impulse %f", impulse->normalImpulses[0]);


That did the trick!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: Exabot [Bot] and 1 guest


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

Search for:
Powered by phpBB® Forum Software © phpBB Group