Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6748007
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:30:50+00:00 2026-05-26T12:30:50+00:00

I have a main character in my Box2d game that has a b2PolygonShape collision.

  • 0

I have a main character in my Box2d game that has a b2PolygonShape collision. When the player crouches I am changing the body to a smaller b2PolygonShape. The logic works fine, but when I change the size (height) of the collision the character starts to fall.

Is it possible to create the new body with an offset (localPosition?) so the position of the body stays the same? This way I can play the crouch animation and change the collision without worrying that the position will change and make my sprite go bananas.

enter image description here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T12:30:51+00:00Added an answer on May 26, 2026 at 12:30 pm

    It’s been a long time since I’ve used Box2D, but I believe I have a solution for you.

    You can create another b2PoligonDef using the b2PolygonDef.SetAsOrientedBox (it allows you to set the center of the Box), and change the shapes like you’re doing now on crouching and standing.

    So if you were previosly using the definition of the crouching box as shapeDef.SetAsBox(1.0, 1.0), now you would change it to something like shapeDef.SetAsOrientedBox(1, 1, new b2Vec2(0, -1)).

    Another option would be to declare the vertices on their own, so you would do something like:

    shapeDef.vertexCount = 4;
    shapeDef.vertices[0].Set(-0.5, 0);
    shapeDef.vertices[1].Set( 0.5, 0);
    shapeDef.vertices[2].Set( 0.5,  1);
    shapeDef.vertices[3].Set(-0.5,  1);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a game engine class that creates my main character instance and game
I have main table called 'Employee' and another slave table called 'EmployeeTypes' that has
I have a game world that's much bigger than the view port, the main
i have a node (named 'terrain') that i offset so that my main game
In my main file I have an array of character strings, char names[320][30], and
I have main window which has inner grid components. When I press a button
Splash I have main activity UI startup operations that take between 5-10 seconds (that
I have a main-section div that is set to inherit it's height from its'
i working on a c++ string library that have main 4 classes that deals
I've my main custom listactivity class that have a instance object of my custom

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.