I have many instances in which I need to use a property to control if the player is on the ground or not. How can I create this? The simple approach that comes to mind is to create a plane over all the floors and give it a property, "floor". Whenever the player is colliding with it, "collide" will be set to true. Else, it will be false. This seems messy and confusing, especially with a large, complex map with rough terrain, ramps, etc. I am looking to create this in a more ideal fashion, how can I create this? Thanks.
Collision with an object that has a Property "floor" is in a lot of situations a good solution. You can have any number of such "floor" objects.
Unfortunately, this might not be sufficient in other situations. E.g. such an object might collide with the top of your character rather than the bottom.
There are other options:
- have a separate object below the character to detect the floor via collision
- use a ray along -Z to detect a floor
As this checks for any object and you can have as much objects with the property "floor" there is no need for a single floor object.
A different thing is to check if the player remains within expected parameters (area). E.g. if you can't be sure he finds a way to jump outside the level. To avoid that you can surround your level with a "consistency cage". You assume the player never touches it, but if he do you can perform some "corrective" actions. For example: game over, level restart or move him back somewhere within the level.
I am not sure if I understood the question correctly, but the collision mesh can be simpler then the actual floor and still have the information needed to make the object interact properly.
Of course this comes at the price of not having the best precision and giving some areas where the interaction may result in it going through or colliding prematurely but the amount of detail is for you to decide.
wouldn't it be better to give the floor itself a property floor? (maybe a boolean). then you can see if the hitObject you get from your player has this property and if it is true. Also, i've noticed you can set the skin of your armature to be a sensor, and use that as your collision mesh.