How would you make an entity explode if, it collided with another, the explosion would just be squares thrown in random directions
For detecting collisions between objects check this tutorial:
And here is a particles based explosion effect:
Thanks, but i dont see anywhere how i get it to explode without fire, i just want blocks to fly everywhere after
Aha, sadly there isn’t any method like that in Playcanvas.
You will have to code it yourself to achieve that effect.
What do u suggest i do
You can try using a number of hidden elements that you enable for the duration of the effect, and you tween them (move them) from start/end pos using the Playcanvas tween library:
Or if your game is already using physics you can place them at the location of your explosion and apply forces at random directions.
Great idea, i have 2 kinematic objects, how do i stop them from colliding or going into each other, i jus want them to bump
Normally to have them bump, you will have to use dynamic objects with real mass. That way physics will do the trick for you.
But if for any reason you can’t use dynamic rigid bodies, then you will have to detect when they collide and manually stop any movement. Use an if statement in your update loop, checking if the two objects are colliding, if it’s true stop moving them.
Ok i have the if code ready, how would i detect if they collide then make them have restitution
Check the tutorial I posted above, posting again here, on how collision detection works:
For restitution you will have to use dynamic objects.
Ive reverted back to dynamic capsules, now they bumb but not collide which is perfect, but now they wont rotate
Yes, lookAt won’t work in dynamic objects.
You will have to estimate the rotation (not so easy) and rotate them using torques:
Thats nice and all but how do i get it to lookAt the other entity all the time, give an example of code, i just tried everything, its like my nob wont rotate and move at the same time unless its kinematic which is not an option