EntityType 0-999
Blitz3D Forums/Blitz3D Beginners Area/EntityType 0-999
| ||
Sorry to be posting yet again! I don't get a chance to use the internet that often, and I code a lot, so the questions tend to pile up sometimes. Could someone please explain to me the large range of this command's second parameter? I thought 0 meant the object would not collide, 1 means it'll collide like an ellipsoid, 2 like it's mesh shape, and 3 like a box. So what's 4-999 for? |
| ||
Player_Collision = 1 World_Collision = 2 Collisions Player_Collision,World_Collision,2,2 EntityType Entity,Player_Collision EntityType Entity2,World_Collision or Player_Collision = 55 World_Collision = 17 Collisions Player_Collision,World_Collision,2,2 EntityType Entity,Player_Collision EntityType Entity2,World_Collision or Collisions 55,17,2,2 EntityType Entity,55 EntityType Entity2,17 |
| ||
The EntityType number is basically a group number. It is used to define the specified entity as being in the specified entity group. The entity groups are mainly used for grouping entities for collision purposes. Internally, the EntityType numbers are actually used as array index numbers in an array with 1000 array slots, which is why the numbers are restricted to the range 0-999. An EntityType number of zero indicates that no collision checking will occur with that entity. This array (or possibly multiple arrays) is created by the code in the Blitz3D runtime DLL and is not something you have access to, or need to worry about. Just keep your EntityType numbers in the range of 1-999 for any entity that you want to be involved in collisions. The EntityType number is mainly used in the first two parameters of the Collisions command. The first parameter is the EntityType number for a group of source collision entities (these entities should have an ellipsoid collision volume, and will be able to be mobile). The second parameter is the EntityType number for a group of target collision entities (these entities can have any type of collision volume, and if they are non-ellipsoids they must be stationary for collisions to be effective). Note that the collision tests are actually carried out when the UpdateWorld command is encountered - the Collisions command just sets the configuration of those tests. |
| ||
Oh, I guess I confused this with Collision method, it has nothing to do with the shape! :D My mistake. Okay, so can I just always make the character type 1, the level parts type 2, and leave it at that? It just seems like if this were any other command, the docs would say, "for characters use 1, level parts use 2, and no collisions use 0," and if you put any other number, nothing would happen. I guess I just don't follow why it's 0 through 999. Are you saying it has to do with some low level stuff that helps Blitz do collisions faster, otherwise it would have just been 0 through 2? If so, does that mean 3 through 999 can be ignored basically? |
| ||
hi you can have many groups (no more than 999) with diferent types of methods of check collisions and diferent responses. When an enemy collide the scenary could stop, but other type of element (a car) could slide. You can define how a car vs scenary react, how a car vs enemy react, how you (player or cam) react against scenray, car or enemy. All the cars should have the same CollisionType all the enemies has other or have groups of elements and dictate how they react when collide with each other. One of the parameters (the second) dictate how react type A when collide with tipe B, but tipe B coul has another reaction when collide with A. The firs parameter dictates what is taking to acconunt to determine if both are collided. EntityBox, radius etc. Hope you understand me (my enlish is very bad!) cheers Juan |
| ||
If so, does that mean 3 through 999 can be ignored basically? If you don't need to set more than one type of source-to-target entity collision behaviour, then you can get away with just two EntityType groups - one for the target collision entity group, and one for the ellipsoid source collision entity group. You really only need to worry about setting up additional collision interactions if you actually find that you need to do so. You may find that you do need to set multiple collision behaviours between different groups of entities, however. You may find that you need game characters to slide when they collide with level geometry, or with other game characters, for example. You may also find that you need bullets and other projectiles to stop without sliding when they collide with level geometry, or game characters. In this case you would need to set one EntityType for the level geometry; another for the game characters; and another for the bullets, and then use the Collisions command to set the various behaviours between the different sets of source and target entities. Note that non-ellipsoid collision target entities need to be stationary for collisions with them to register. eg. Const ELLIPSOID_TO_ELLIPSOID_COLLMETHOD = 1 Const ELLIPSOID_TO_POLYGON_COLLMETHOD = 2 Const ELLIPSOID_TO_BOX_COLLMETHOD = 3 Const STOP_COLLRESPONSE = 1 Const SLIDE_COLLRESPONSE = 2 Const SLIDE_UP_COLLRESPONSE = 3 Const LEVEL_GEOMETRY_COLLTYPE = 1 Const GAME_CHARACTER_COLLTYPE = 2 Const BULLET_COLLTYPE = 3 level = CreateCube() EntityType level, LEVEL_GEOMETRY_COLLTYPE character = CreateSphere() EntityRadius character, 1.0 EntityType character, GAME_CHARACTER_COLLTYPE bullet = CreateSphere() EntityRadius bullet, 0.01 EntityType bullet, BULLET_COLLTYPE Collisions GAME_CHARACTER_COLLTYPE, LEVEL_GEOMETRY_COLLTYPE, ELLIPSOID_TO_POLYGON_COLLMETHOD, SLIDE_UP_COLLRESPONSE Collisions GAME_CHARACTER_COLLTYPE, GAME_CHARACTER_COLLTYPE, ELLIPSOID_TO_ELLIPSOID_COLLMETHOD, SLIDE_UP_COLLRESPONSE Collisions BULLET_COLLTYPE, LEVEL_GEOMETRY_COLLTYPE, ELLIPSOID_TO_POLYGON_COLLMETHOD, STOP_COLLRESPONSE Collisions BULLET_COLLTYPE, GAME_CHARACTER_COLLTYPE, ELLIPSOID_TO_ELLIPSOID_COLLMETHOD, STOP_COLLRESPONSE |
| ||
Oh I see, so say the character is 1, you then have virually limitless settings you could give the other objects depending on what number you give them, but the numbers themselves are pretty arbitrary, right? |
| ||
Yeah, the number are whatever you want them to be. Just watch how many different entity types you set, or you might end up really slowing your game up with collisions. |