Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在创建一个基于物理的游戏。如图所示,我有一个坦克。它的头部是可旋转的,所以我想向坦克头部当前角度的方向发射一个球。如何对这个身体施加力,使其能够朝着坦克头部的方向移动?
body->SetActive(true); float magnitude=800; b2Vec2 force = b2Vec2((cos(body->GetAngle()-4.7) * magnitude) , (sin(body->GetAngle()-4.7) * magnitude)); body->ApplyLinearImpulse(force, body->GetPosition());