How do I…
I am creating a simple FPS with the 3D Extension of WithThreeJs. I am trying to create particles at the X,Y,Z coordinates of the collision between a fired bullet and other objects (for example a wall). The reason is, that I want to create feedback for the player when a bullet hits something.
What is the expected result
When I fire a bullet and it hits something, it should create particles at the exact point of collision between the bullet and the object that got hit.
What is the actual result
Everything works fine, just the X,Y,Z coordinates where the particles are created doesn’t match the actual X,Y,Z of the collision. I cant seem to find the right expression for it. I tried center, .X .Y and Bounding Box. They do not work.
Maybe you have an idea. I am very thankful for your help!
I’m not sure if you can get the point of collision for 3D objects but I know for sure you can’t with 2D objects. What you can do is get the position of the bullet object (if you are not using ray casting) when it collided with something.
thanks for you reply. I tried that, but it didn’t work. I think its because I made it that when the bullet hits something, it deletes the bullet object. I thought that if I would delete the bullet afterwards in the function, it would maybe work. But it does not.
So maybe I am thinking that with a timer to delete the bullet lets say 0.3 seconds later, it works. I will try that out right now.
EDIT: It doesn’t work. The particle effect is created at 0, 0 in the left upper corner of the scene.
For some reason there seems to be a problem with bullet.X() and .Y(). Maybe I am using the wrong expression here?
Probably the bullet is being deleted before you create the particle. So in collision event try, bullet in collision with anything, create particle at bullet, delete bullet.
The x and y could be opposite depending on the way you setup the scene, I know I had this problem. Also, I don’t think you can use particles in 3d.