Jump to content

Box2dWeb: rotating object about a point


Abhishek Bharti
 Share

Recommended Posts

Hello,

I am having problem rotating box2d object back and forth around a point.

To better understand my problem i have prepared an example clicking on key rotate the paddle when u click again the paddle rotate back to its initial position.

http://abhishekbharti.pe.hu

 

i want to simulate something like this in box2dWeb.  

Thanks in advance :)

Link to comment
Share on other sites

(SOLVED) finally i solved the puzzle,

To get the paddle back to its initial position i just need to counter gravity by applying force to that paddle in opposite direction of gravity like this: body.ApplyForce(body.GetMass()*-world.GetGravity(), body.GetWorldCenter());  need to apply this force every frame.

 

This article here helped me:

http://www.iforce2d.net/b2dtut/custom-gravity

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...