Hi all,
Is there a way to sense collision of one entity with another specific entity (not just any rigid body)?
Hi all,
Is there a way to sense collision of one entity with another specific entity (not just any rigid body)?
Unfortunately, not directly through the PlayCanvas API. You have to use the Ammo.js API to set groups and masks. Collision masks / Groups
Edit: Actually, what do you mean by āsenseā? As in, how do you know what type of object has been collided with? Or do you want one rigidbody to pass through some but not all other rigidbodies?
In which case the thread on groups and masks is what you need.
Can you please give an example?
There should be a few examples and explanations in the thread I linked above.
I canāt find the link
Sorry @yaustar, Iām not quite getting what you said in the thread you looked above. Can you please explain again?
Ah, I was under the assumption that you knew what collision groups and masks are. This page should explain: http://www.bulletphysics.org/mediawiki-1.5.8/index.php/Collision_Filtering
All the script is doing in the example of the other thread is setting the filter masks and groups on the rigid body.
Worth noting that PlayCanvas has some pre-defined masks - so donāt make the mistake I did and overwrite them.
Ah, yes. I did that the first time too
Is there a way I can just find the entity by name and check if there is a collision?
Instead of other. rigid body?
Maybe if (result === this.app.root.findByName(//name of entity)
If you want some objects to pass through and not others (which I asked you earlier in the thread), then unfortunately, no.
If itās a case of, ādid I hit a tree or a wall or another car?ā, then you donāt have to worry about physic groups and masks and just use entity tags instead when checking in the collision callback.
Can you send a script showing how to do that?