Maximum collision objects?
Blitz3D Forums/Blitz3D Programming/Maximum collision objects?
| ||
Hi, just wondering if there is a maximum number of objects you can setup collision detection with and when I might hit a problem... Currently my player object tests for collisions with about 120 game objects with no problems so far... |
| ||
My current project involves a lot of objects testing for collisions (specifically, bullets.) There is a slowdown associated with those objects colliding with stuff, but the slowdown is due to the explosions generated on impact and not the collision detection itself. |
| ||
In fact the EntityType range is 0-999 so the maximum number of collision objects is 1000. How many do people have? It's looking like having 120-200 or so is not gonna cause a problem I suppose. |
| ||
Entities with the same EntityType can be set up to collide with each other, so 1000 isn't the "maximum number of objects you can setup collision detection with." I suspect if you're using up to 200 EntityTypes, you're not using them correctly. Why do you need 200? |
| ||
for example I have 16 gas masks that could be placed anywhere within the world. I need to test for a player actually finding one so I have 16 collisions setup between the player and each of the 16 gas masks. Then I have gas clouds, teleports, teleport triggers, doors, keys, timebombs, unstable blocks etc... |
| ||
Each of the gas masks can share the same collision group matey :) |
| ||
This is indeed not necessary boiled sweets. You just assign a number for all the gas masks, for example: - Type = 5 -> Gas Masks - Type = 6 -> Doors Then, when colliding with type gas mask, just get the entitycollided... |
| ||
But each gas mask has different properties. For example gas mask 1 works for 2 seconds and gas mask 2 works for 10 seconds. If I just test for a collision then I will know its a gas mask but which one? So I assign a different EntityType for each gas mask so then I can go thru a loop and compare the EntityType to the Entity and work out which specific gas mask I have. How would I do it other wise? |
| ||
Why don't you simply do a distance check? Loop through ever gas mask, and use entitydistance to check the distance. If it's within a certain distance, your touching it :o) EntityDistance is lightning quick too :o) |
| ||
Presumably your gas mask 'object' is a type? If so, you can store the handle of that specific type instance as the associated mesh's name.NameEntity mesh,Handle(this.gas_maskT) then, when a collision occurs and you have the gas mask entity involved: this.gas_maskT = Object.gas_maskT(EntityName(collided_entity)) This is an old trick that uses the undocumented Handle and Object commands. It saves having to iterate through all your gas mask types in order to find the one with the collided mesh. However, if your game has relatively few gas masks, you can always use that method without much of a speed hit, I suppose. |
| ||
But each gas mask has different properties. Ahh, you're storing information in the EntityType of entities. EntityName is another place to store information, and won't mess with the collision system. You could simply store the same number you're using to identify objects in your entities' EntityNames instead. Or use it as a Handle(), like big10p explained. I always thought EntityType was a poor choice of names for that field. EntityCollisionType would be better. Chances are that you don't need more than a bare minimum of EntityTypes: 1 = level 2 = powerups 3 = enemies 4 = player 5 = player bullets Collisions: 1+3, 1+4, 1+5, 2+4, 3+4, 3+5 |
| ||
You have hundred of possibilities of storing additional values within an entity. Just a few: 1 - Use Types 2 - Use Dims 3 - Use Vectors 4 - Use EntityName (above commented) 5 - Use colors Etc... :) |
| ||
I would strongly advise, if your using sphere to sphere collisions, using the entitydistance method. Far quicker then using the collision system. |
| ||
Ross C is Right. If you don't need the slide collision, use entitydistance! |
| ||
I double that, using collision for this kind of task is a waste of cpu time. Personally I would use EntityName and name them with something that contains an index (eg. "gasmask_123"), so I could access an Array or Bank region with all the needed information about the object. |