Archived

This topic is now archived and is closed to further replies.

DiablosIII

How to make 3d objects non-walkable...

Recommended Posts

Here is the code. If I use it for 1 object it works but when u use it for more then 1 object the computer confuses. This is only for the up key. ---------------------------------------------------------------- HRESULT CALCULATEUP(COBJECT xOBJECT) { PLAYER.fRotateY = 0.0f; PLAYER.ROTATEY(PLAYER.fRotateY); if((PLAYER.fTranslateZ == xOBJECT.fTranslateZ + xOBJECT.fFrontside) | (PLAYER.fTranslateX < xOBJECT.fTranslateX + xOBJECT.fLeftside) | (PLAYER.fTranslateX > xOBJECT.fTranslateX + xOBJECT.fRightside)) { PLAYER.fTranslateZ -= 0.00f; } if((PLAYER.fTranslateZ > xOBJECT.fTranslateZ + xOBJECT.fFrontside) | (PLAYER.fTranslateZ < xOBJECT.fTranslateZ + xOBJECT.fFrontside - 0.05f) | (PLAYER.fTranslateX > xOBJECT.fTranslateX + xOBJECT.fLeftside) | (PLAYER.fTranslateX < xOBJECT.fTranslateX + xOBJECT.fRightside)) { PLAYER.fTranslateZ -= 0.05f; } PLAYER.TRANSLATE(PLAYER.fTranslateX, PLAYER.fTranslateY, PLAYER.fTranslateZ); return S_OK; } ---------------------------------------------------------------- I now where I made the mistake but I don''t now how to fix it. The problem: Say you have something like this ---------------------- if(Key = Up) { CALCULATEUP(CUBE1); CALCULATEUP(CUBE2); } ----------------------- and you are near cube1 and far from cube2 and you press the up key. Now the computer thinks that even when you are near cube1 you are still far from cube2 so you may walk, because I use the last part of the code twice: ----------------------------------------------- if((PLAYER.fTranslateZ > xOBJECT.fTranslateZ + xOBJECT.fFrontside) | (PLAYER.fTranslateZ < xOBJECT.fTranslateZ + xOBJECT.fFrontside - 0.05f) | (PLAYER.fTranslateX > xOBJECT.fTranslateX + xOBJECT.fLeftside) | (PLAYER.fTranslateX < xOBJECT.fTranslateX + xOBJECT.fRightside)) { PLAYER.fTranslateZ -= 0.05f; } ------------------------------------------------- Thats the problem. Anyone now how to fix it?

Share this post


Link to post
Share on other sites