Jump to content
  • Advertisement

Archived

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

DiablosIII

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

This topic is 5994 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!