Is it possible for the player to hit a box and another box will lose its rigidbody or collision? Like a button, then a box, like a door? At first, the collision and rigidbody will be on (locked) then when you hit a lever, the door will “unlock”.
Hi @thebosser24! Please give your topics a short but powerful title and ask your full question in your topic. To answer your question, yes this is possible. You can create a trigger and use this trigger to change the rigidbody type of another entity (for example from static to dynamic).
1 Like
im sorry
how do i make the trigger, and make it change the collision
First you need a new entity with a collision and script component. Set the entity on the correct place in your scene. You also need to create a new script with the name ‘Trigger’ and add this script to your new entity. Open te script and replace the code with the code below. After that your trigger is done. For the next part you need to show me your other entity.
var Trigger = pc.createScript('trigger');
// initialize code called once per entity
Trigger.prototype.initialize = function() {
this.entity.collision.on('triggerenter', this.onTriggerEnter, this);
};
Trigger.prototype.onTriggerEnter = function(entity) {
// Next part
};