简体   繁体   中英

Anchoring a box2d body

Is it possible to anchor a Box2D body to a specific X value, but still leave it able to move freely on the Y axis? I feel like a prismatic joint may be necessary for this, but I had some trouble setting it up. Thanks,

Tate

Just limit the LinearVelocity

...//detect the velocity
b2Vec2 v = body->GetLinearVelocity();
v = b2Vec2(0,v.y);
body->SetLinearVelocity(v);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM