End Object Not Working

I have a really simple scene I was using to test adding bullet holes. It’s just a cube that fires a smaller cube (bullet) at hits a larger cube that I made thinner, like a wall. The cube that fires is set to static, the wall is set to static, and the bullet is set to sensor (so it will collide with the wall but not drop to the ground). I fire the bullet at the wall and depending on the angle, the bullet goes right through the wall. I’m not sure what’s wrong.

I think it’s happened because the bullet is going too fast, there is not problem with end object. To make a bullet hole is recommended cast a ray and spawn the bullet at the position that hit the ray.

Try reducing the velocity of the bullet.

Yeah that fixed it. Which raises another question: How do I get the bullet do go fast and still hit the wall? In the game I’m making, you’re going to be able to see the bullet, it needs to be going fast.

Never use simple motion (or Python: applyMovement) for projectiles. This ‘warps’ the projectile from one location to the other at every logic tic. That’s why it will go through walls without even colliding with it.

Solution. Scale the projectile in length so it will virtually hit everything on its path, because the distance it travels at every logic tic will be smaller than the size of the bullet. You could use two object for this, a physics mesh which will be invisible, and a display mesh parented to it. Or as carlo697 mentioned, use rays, which is recommended.

That is a problem, when a object is moving, it is “teleporting”(even if you are using linear velocity), in a frame the object have a position, and at the next frame have another position, so if the object is moving fast, the object can not be colliding with the wall in any moment, the ways would if the game is running at many frames, increase the size of the object, do it move more slow, which are not real solutions(the problem still present in sometimes), could be said to there is no solution.

Is for that games not use methods like that at the moment of make shooters, as I said, the method used to do thing like that is cast a ray.

How would I use a ray to end the bullet?

The ray is for get the position at the moment of it hit the wall, originally you say you are doing a bullet hole, the idea to make a bullet hole is:


-At the moment of the shoot cast a ray from the camera to the front.
-If the ray hit, get the position the position of the hit.
-Spawn the bullet hole in the last position.
-Other things for adjust the bullet with the wall.

To cast a ray you need a ray sensor in the camera, the action that trigger the shoot(like the mouse click), to get the position of the ray and spawn a object using it you need a python script(ray.hitPosition to get the position, and scene.addObject for spaw the object).

And spawn a bullet at the moment of the shoot is another bad idea, use again a ray, if the ray hit a enemy, restart to the enemy the value of the property that represent the life.

That’s a good question. But there’s a trick to it. You’ll have to use a Python script for this.

On the player you need a script to cast a ray and add the bullet to the scene (with a speed). To measure the time of impact you have to calculate the distance between the gun and the rays hit position and divide it by the speed of the bullet. Cast this value to an integer and store this on the bullet. A script on the bullet will run as long as this value and then remove it.

If it’s to complicated I could make you a small example. Let me know what you like.

Edit: I feel a little silly. It’s much easier to use the ‘time’ parameter with addObject(). I’ll post an example shortly.

Edit2: I think I previously didn’t use the ‘time’ parameter because it has a bug. I probably forgot. But there’s an easy fix. Here’s the example:

Attachments

Ray_bullet_example_00.blend (94 KB)