I’ve been trying to figure out the best function, or set of functions, to use to determine the count of GameObjects that are stacked on a platform, using collision.
As an example, we have a platform with a sign that reads the number of objects that are stacked on the platform. I have the platform scripted to count and display the objects that are on IT, but when i begin to stack them, obviously they aren’t colliding with the base platform anymore so it doesn’t count them, however they are on objects that ARE on the platform.
What would be the best and most efficient method to determine the amount? I have already begun theorizing several methods, however they all seem a little… out-there, lol.
I figured someone on here might have a simple solution: just as a heads up, I’m not asking for full scripts, I’m just looking for ideas. I can do the coding on my own, ^^
I thank you, in advance, for any help you’re able to provide for it will be greatly appreciated as well as save me a lot of time and over-thinking, xP
Maybe a secondary collider on the platform thats set as a trigger, that goes up for whatever the max amount of objects on the platform is going to be, that way there are always coliding with the platform even though there not actually touching it.
Hmm, the only thing keeping that from working is that I’m using dragrigidbody for the object placement/reorganization. So having a trigger collider covering that area would intercept the raycast from dragrigidbody.
I was thinking of resorting to each object that collides with the platform has a script attached to it. Have that script check for collisions above it and add that same script to those objects while having the script also add the counts to a variable which is taken by the platform.
The only reason I’m not using this is that I feel there has to be a simpler way or at least a more efficient one. Cuz I don’t wanna have to constantly clean up scripts from these objects if they are removed from the stack or something… it just seems too sloppy.
Hmmm… could you just put the platform on ignoreraycast layer so the collider would interfere with the raycasts?
Ok, I didn’t even think about that one. Now I gotta try it, I don’t see why that wouldn’t work. Thanks, xD
No problem, glad to help.