I am trying to find a way to set a game object’s collision group dynamically on it’s init function, but I can’t find how. Isn’t it possible?
I believe that it isn’t. Are you using a GO or Collection factory? If you want to set it in the init, can’t you just set it in the collision group’s settings?
Currently using a go factory.
Yeah, I said that wrong, not in init, but as soon as I create it in the factory. The factory spawns objects for two different teams and I wish I could filter collisions just for the adversary. Guess I’ll have to do it via an if statement…
Hmmmm… I can think of two things:
- make two different GO factories if that fits your needs? One for each time?
- you should also remember that you can get other_id in the collision table to see what object you’re colliding with. That might be helpful to you depending on your case
That’s what I am currently doing. I was trying to set the groups to avoid wasting performance on unnecessary collision checks, but oh well, that’s life. Thanks!
This would be a good feature request!
You can have a single game object with two different colliders and disable the one you don’t need.
This is a possible workaround, but you need to create a collisionobject for each group you want to have (remembering about a limit - max 16 collision groups)
One collision object has one group and can have multiple masks - so you can specify with which groups should a certain group interact/collide.
Then you can change it in code:
msg.post("#collisionobject", "disable") msg.post("#collisionobject", "enable")
Vote for it! [ ]
Yep, please vote for features that are important to you!
There’s a way to sort issues by most reactions!