Can a Collider differentiate between two objects?

Hi! I have not found much information about collisions in Lens Studio.

But I don't know if it is possible to differentiate whenever Object A or Object B collides with my main collider. In Unity I would use tags but I haven't found a way in Lens.

This is the script just in case it helps:

// -----JS CODE-----
//@input Component.Text currentScoreNumber
//@input Component.Text finalScoreNumber
//@input Component.Text3D finalScoreNumber3D

var currentScore = 0;
var sceneObjj = script.getSceneObject();
var rb = sceneObjj.getComponent("Physics.ColliderComponent");

rb.onCollisionEnter.add(function (e) {
var collision = e.collision;
currentScore ++;
script.currentScoreNumber.text = currentScore.toString();
script.finalScoreNumber.text = currentScore.toString();
script.finalScoreNumber3D.text = currentScore.toString();
print("CollisionEnter(" + + "): ---> " + collision.collider);



Thanks in advance!


  • Kevando
    Kevando Posts: 74 🔥🔥

    Yeah colliders should have a tag or something. I bet gives you the object name or something like collider.getSceneObject().name should work. bottom line is yes, you can do this.