Explosion on colision

0
TheKaijuGirl posted this 3 weeks ago

Hi everyone ! I use picavoxel to do a space shooter game but i have a problem : When i try to use the explode function oncollisionenter, the explosion is alway in the same point, not in the colision point.

Can you help me ?

7 Comments
Order By: Standard | Newest | Votes
0
GarethIW posted this 3 weeks ago

Can you please post your collision code and maybe a screenshot of how you have your bullet set up? I’m assuming this is a bullet you’re colliding?

0
TheKaijuGirl posted this 3 weeks ago

Yes, that's it. The script :

public float bulletSpeed = 10;
public Exploder xp;
public Rigidbody rb;

void Update()
{
    rb.velocity = transform.forward * bulletSpeed;
}

void OnCollisionEnter(Collision col)
{
    if (col.gameObject.name == "PicaVoxel Volume")
    {
        xp.Explode();
        Destroy(gameObject);
    }
}

And this is the setup of the bullet : https://ibb.co/mFpvD9d

Last edited 3 weeks ago

0
GarethIW posted this 3 weeks ago

Okay, can't see anything wrong there. Maybe a screenshot of what is happening with the explosions?

0
TheKaijuGirl posted this 3 weeks ago

https://www.youtube.com/watch?v=DDWD-eNn4MI&feature=youtu.be

0
GarethIW posted this 3 weeks ago

Hmmm, i'm not sure what's going on there. You will need to tone down the explosion quite a bit (see this topic http://forum.picavoxel.com/chat/collisions-cause-framelag-freezes). It looks like the bullet is going through the volume before it explodes?

Things to try: - turn on the Mesh Collider on the big cube. Make it concave. - disable the Hitbox gameobject that is the first child of the big cube Volume. - Turn your explosion radius down, or increase the size of your voxels on the cube ;)

0
TheKaijuGirl posted this 3 weeks ago

Well... i follow your advice and now it's worse, it didn't explose at all :/

https://youtu.be/RlDRhMErK68

Edit : nevermind, i'm stupid, i forgot to disable the "ontrigger" ._. Another question : when i explode a part, their is still the hitbox, so i can't destroy part behind destroyed part

Edit 2 : nevermind too, i found it myself :D

https://www.youtube.com/watch?v=ksiuV2SxvLY

Last edited 3 weeks ago

0
GarethIW posted this 2 weeks ago

Sorry i didn't get back to you, I was doing a show at the weekend and then launched my game into closed beta, so I've been busy!

I see you solved your problem, but for future reference, I put together a bullet collision script that works without relying on the PicaVoxel Exploder script, and is a bit more efficient and reliable.

https://gist.github.com/GarethIW/41087d8c211373d1e5215eb69cea481e

To make this work, the target Volume had a Convex collision mesh, and you can alter the radius of the bullet's explosion and the speed at which the particles spawn directly on the bullet itself.


Our 132 members have posted 493 times in 119 discussions