0

How i can make player to dont go inside walls

An idea i have is to create a class that draw an model, in that constructor i will add also some informations about model like ID-NAME-Position.

So i will create an function that will check if

if ( Abs(Player.XYZ - Wall1.XYZ) < 500)
       return;

But as you understand this is not possible when you have 100 objects, you cant have 100 ifs.

So any idea to solve this problem? thanks.

2
Contributors
1
Reply
2
Views
5 Years
Discussion Span
Last Post by sfuo
0

No matter what, collision detection is just going to be a bunch of if() statements. The way that you prevent checking way more objects than you need to is by dividing all your objects into a quadtree or an octree. You then check if your player is within one of the outer nodes and if it is then you work your way in to see what objects you are colliding with.

You should make a program that loops 1000000 times with an if() statement in it and see how many milliseconds it takes. You will be suprised at how little time doing if() checks take.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.