本文整理汇总了C++中GameScene::GetPhysxProxy方法的典型用法代码示例。如果您正苦于以下问题:C++ GameScene::GetPhysxProxy方法的具体用法?C++ GameScene::GetPhysxProxy怎么用?C++ GameScene::GetPhysxProxy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GameScene
的用法示例。
在下文中一共展示了GameScene::GetPhysxProxy方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Raycast
void Player::Raycast(const GameContext& gameContext)
{
GameScene* scene = GetScene();
XMFLOAT3 pos = GetTransform()->GetPosition();
XMFLOAT3 fw = GetTransform()->GetForward();
PxVec3 rayOrigin(pos.x,pos.y + 1.f,pos.z), rayDirection(fw.x,fw.y,fw.z);
rayOrigin.x += fw.x * 2.5f;
rayOrigin.z += fw.z * 2.5f;
const PxU32 bufSize = 20;
PxRaycastHit hit[bufSize];
PxRaycastBuffer buf(hit, bufSize); // [out] Blocking and touching hits will be stored here
if(scene->GetPhysxProxy()->Raycast(rayOrigin, rayDirection, 5000, buf))
{
for(PxU32 i = 0; i < buf.nbTouches; ++i)
{
BaseComponent* component = static_cast<BaseComponent*>(buf.touches[i].actor->userData);
GameObject* go = component->GetGameObject();
string name = go->GetName();
cout << "RAYCAST OBJECT: " << name << endl;
if(name == "Enemy")
{
Enemy* enemy = reinterpret_cast<Enemy*>(go);
int dmg = 12.5f;
enemy->Damage(dmg);
}
}
PxVec3 vel = rayDirection * 1000;
auto laser = new Laser(XMFLOAT3(vel.x, vel.y, vel.z));
AddChild(laser);
}
}