Why does Blender Quit when i use this Script?

I have used an old bullet hole script, its not mine (im not sure who’s it is, it might look familiar) it runs ok when its on its own. But i made my own script, and im not sure if the problem is related to the original script, but it shut’s down blender anyhow… here is the script …

import GameLogic as GL
from Mathutils import Vector
cont = GL.getCurrentController()
own = cont.owner

# Get controller
controller = GameLogic.getCurrentController()

#get Object
spawn = controller.owner

# Actuator
setParent = cont.actuators["Parent"]

# Sensors
mouse_click = cont.sensors["mouse_click"]
ray = cont.sensors["ray"]

# get the game object hit by ray
gameObj = ray.hitObject

# Set parent
spawn.setParent(gameObj, 0, 1)

ty, and with love
ATomCat :smiley:

Here is the .blend, it was trimmed to make it fit, i know its 300kb i dont know how i got it so small. anyway, plz tell me if it crashes blender for u aswell


BulletHole (trimed).blend (307 KB)

cool script!

For me is crashes blender after a shoot like 13+ bullets… I don’t know what the problem is though :frowning: sorry!

I opened it and it also crashed on me as soon as I started the game.

I found something that makes it stop crashing, but I am not sure if it is how you want the game to work.

A property was missed. The object being shot at “cube.003” had a “Rigid” property.
Your Ray sensor wasn’t working without a property in the property value box. For everything that you shoot at, you would need to make a common property if you’re going to use the Ray sensor. I put the “Rigid” property inside the ray sensor and it didn’t crash.

Hope it helps:)


BulletHole%20(trimed)[1].blend (265 KB)

Its a parenting problem. When you parent an object to itself blender crashes, I don’t know why there isn’t an exception for this.

So the hitObject is returning a bullet hole, and when you try and parent the new bullet hole to the hit bullet hole they are being interpreted as the same object, even though they are different instances. To solve this change the bullet hole’s physics type to “no collision”, this way bullet holes won’t be returned as hit objects.

Nathankl’s method solves this problem as bullet holes are not being returned.

Yay, thnx guys it doesnt crash (thnx Linkxgl btw) but another problem has occuerred. When i shoot the floor, then the box, and then move the box the hole on the floor becomes parented to the box. The only way i can think of right to go about fixing this is making each bullet hole a seperate objects all together. But, not only do i not know how to do that, but there might a better way. So could u guys help me out with that aswell… ty for helping before btw, i was so happy, like, literally.:smiley:

lol (lots of love, lol),

I have no idea what the spawn_parent script does, just get rid of it.

Fix up the set parent in rayBullet to say bullet_hole.setParent(gameOb, 0, 1), should work after that.

Ah, that fixed it, thnx… didnt even think of that:o. ty guys

ily all!!!