Toggling "Ghost" Physics Withing Game Engine?

Hi everybody, hopefully just a quick question here: is it possible to quickly turn the ghost physics setting for a dynamic object on and off within a game? And if not, what would be the best way to allow an object to fly through certain objects but not others? I was thinking you could designate which objects could be flown through with a property, but I wasn’t sure how to actually allow the object to go through them.

I think the only way to toggle ghost in realtime is parent the object to another, but makes your object can not move.

To do what you want maybe you will try use collision groups and mask:


can’t you use replace mesh->ghost mesh?

hmm is this a bug?

what is replace physics mesh for if it does not replace the physics mesh?

spacebar = replace mesh…

Attachments

physicstest.blend (449 KB)

I think the method that gets picked every time this comes up is to have two objects, and use the addobject and endobject functions.

@BPR: It’s not broken, but only supported with Triangle Meshes. Hover over the Physics button on the Actuator for that info. But unfortunately Triangle Mesh is not suitable for Dynamic objects, so it can be said that Physics mesh replacement is not working properly with Dynamic Objects. It would be nice if Convex Hull at some point in the future would have properties such as mesh updating (and also polygon detection with rays). It’s either this or to fix the problem with Triangle Mesh, so this would be compatible with Dynamic objects. The commit in the tracker is high priority, but I wonder if it’s even on the agenda, because it would have to be a complicated fix.

@carlo697:
I’ve never looked into using collision groups and collision masks, but now that I have, it appears like they would work. However, I don’t understand exactly how to use them (and my basic trial-and-error test came up short :o), and I’m finding very little information about them on various Blender sites. Would you be able to give me a brief explanation of how they work?

@sdfgeoff:
As I was doing a little bit of research into other threads pertaining to similar topics, I came across the method that you described, but I was unsure of how exactly to trigger the object switch. What would you recommend for this function that would allow the object switch to occur very quickly?

Either use two edit object actuators, one end object, one add object, or you can use the equivalent python funtions.

Sorry, I guess I didn’t explain my question very well. I meant what event would you suggest for triggering the switch, or in other words, what sensor would you use to activate the two actuators?


This is sort of an example of what I had in mind when I originally asked this question. I would want the ball to only collide with the red wall and to be able to pass through the other two walls.

Let me know if I can clear anything else up! :slight_smile:

Collision Groups.
I’ve never used them, but this is what they’re for.

As carlo suggested, collision groups should work fine.

Collision groups are what groups an object belongs to (i.e. “I’m in group A”).

Collision masks are what groups an object can collide with (i.e. “I’m can collide with group A”).

By default all objects are in a single group, and can collide with every other mask. To get your desired result, place the walls you want the sphere to pass through in a different collision group (the walls could be in group B, for example). In the ball, set it to not have that mask slot enabled (so that the ball will not collide with group B).

@SolarLune:
Your explanation of collision groups and collision masks makes perfect sense, and they work perfectly for what I’m trying to do! Thank you so much for our help! :slight_smile: