Make a trap

how do i build something that ball or any thing else when connect with it respawned
project link PlayCanvas 3D HTML5 Game Engine
TY for helping!

@SUPER_ME I am not clear on what actually you are looking for. Do you have a YouTube video to look at or maybe a better description?

i want something like haunters trap for bears.
when bear will go on traps bear will die or haunter will kill that .
i want do this to a ball a roll a ball game that when ball will role on trap ball respawned
like when ball will fall from plans.

@SUPER_ME So the bear trap I think you can get here.

Quaternius • Survival Pack

As far as ball rolling, I think you could get some ideas from creating a new game and selecting the following.

image

i mean something like those pipes in flappy bird game Flappy Bird - PLAYCANVAS

I think you are looking for something like a trigger. For a trigger you need to use an entity with a collision component and a script. You can find more information on the page below.

https://developer.playcanvas.com/en/user-manual/physics/trigger-volumes/

7 posts were split to a new topic: Error ‘getGuid’

could you give me a code thath
if (any thing) connected with (any thing)
do this code

like if cube connect with another cube collison
do cube jump

If for example your player cube has the name ‘Cube1’ you can do something like below.

var TriggerVolume = pc.createScript('triggerVolume');

// initialize code called once per entity
TriggerVolume.prototype.initialize = function() {
    this.entity.collision.on('triggerenter', function (entity) {
        if (entity.name === 'Cube1') {
            entity.rigidbody.applyForce(0, 100, 0);
        }
    });
};
2 Likes

yes it works so 1- creat phisycal shape name it (exam)
2-add collison any shape (name : exam1)
3-add below script to that collison (exam1)

var TriggerVolume = pc.createScript('triggerVolume');

// initialize code called once per entity
TriggerVolume.prototype.initialize = function() {
    this.entity.collision.on('triggerenter', function (entity) {
        if (entity.name === 'exam') {
           // excute this code
        }
    });
};

1 Like