RigidBody changing

How do I make the opposite object’s rigidbodys dinmaki when CameraTrigger hits the opposite object attached to an object. It gives error like this.

CameraTrigger.prototype.onTriggerEnter = function (triggerEntity) {
    //Camera speed and ball speed according to speed
    if (triggerEntity.tags.has('fastcamera')) {
        this.entity.rigidbody.type = pc.BODYTYPE_DYNAMIC;
        
    }
};


Hi @Ozden_Delibas!

If this is your question, then I think you need to replace this.entity with triggerEntity in your code above.

1 Like

triggerEntity.rigidbody.type = pc.BODYTYPE_DYNAMIC;
are you talking about this

Yes, exactly.

1 Like

So how do I destroy the object it touches? It doesn’t give the result I want.

It’s a little bit difficult to say with less information, but maybe something like below?

triggerEntity.destroy();
1 Like

@Albertos I want to destroy the rigidbody of the object it touches, but it doesn’t work.

You only want to remove the rigidbody component?

triggerEntity.removeComponent("rigidbody");

yes

@
I use tirgier to increase the speed or something when I touch an object here.
But then I can’t delete or destroy it why do you think.

Sorry, I don’t understand it. Why do you try to destroy and why it doesn’t work? What is the actual result?

The object in the video comes in front of the camera and no matter what I do, I can’t destroy it.
The reason I destroy is because I can’t shoot.

Is your trigger not working at all? You can check this by adding console.log("check"); and check the console of your browser.

I also suggest to give your trigger a primitive render component to be able to see if it is on the right position in your game. Also make sure sure the trigger has a collision component and no rigidbody component.

1 Like