Need help with collision detection

I’ve just been messing around with a volleyball game, is there a way to have a rigidbody collide with some other rigidbodies but not all?

Hi @Soapy_RL ,
Please check this thread: Layer-based raycast?

we can add rigid bodies to different groups to achieve what you want.
let me know if you need any further help.

First, put

this.entity.collision.on('contact', this.onContact, this);

Into the initialize function. Then somewhere in the script add the contact function, it will look like something like

Scriptname.prototype.onContact = function (result) {
    if (result.entity.tags.has("thetag"))
    {
        // STUFF HAPPENS
    };
};

You might have to remove the “entity” from result,entity.tags.has, sometimes it works sometimes it doesnt and idk why either happens. Remember this is a separate function from things like update and initialize, dont accidentally put it within one of those, treat it like a third version of initialize and update.

Thank you guys so much, that was easier than I thought :slight_smile:

1 Like

Were my script segments of any help?

Oh I haven’t tried it yet, I used groups and masks and it worked, thanks anyways