disable z orientation in "bulletholes.blend" ??

# object properties
#	type	name	value	use
#	Int		ebhole	0		keep track of if I need to position a bullet hole still
# random note about implementation:
#  the gameblender python api give me access to added objects the frame after I trigger the actuator
#  so I have to react accordingly.  

from math import sin, cos, sqrt

# vector functions!!
def VEC_length(x):
	return sqrt(x[0]*x[0]+x[1]*x[1]+x[2]*x[2])
def VEC_normalize(x): 
	length = VEC_length(x)
	return [x[0]/length,x[1]/length,x[2]/length]
def VEC_cross(x, y):
	return  [x[1]*y[2] - x[2]*y[1],
			 x[2]*y[0] - x[0]*y[2],
			 x[0]*y[1] - x[1]*y[0]]
def VEC_min(x, y):
	return [x[0] - y[0], x[1] - y[1], x[2] - y[2]]
def MAT_trackvector(fw, y):
	if abs(abs(fw[2]) - abs(y[2])) < .001: #prevent gimbol lock
		del y[0]
	right = VEC_normalize(VEC_cross(y, fw))
	up = VEC_cross(fw, right)
	return [[right[0], up[0], fw[0]],
		[right[1], up[1], fw[1]],
		[right[2], up[2], fw[2]]]

cont = GameLogic.getCurrentController()
obj = cont.getOwner()
ray_sensor = cont.getSensor("ray_bullet")
lmb_sensor = cont.getSensor("fire")
add_bullet_act = cont.getActuators()[0]

# position the last added bullet hole
newobj = add_bullet_act.getLastCreatedObject()
if obj.ebhole and ray_sensor.isPositive():
	hit_pos = ray_sensor.getHitPosition()
	hit_norm = ray_sensor.getHitNormal()
	# woohoo!
	newobj.setOrientation(MAT_trackvector(hit_norm, [0.0,0.0,1.0]))
	obj.ebhole = 0

# determine wether or not to create a new bullet hole
make_bullet = ray_sensor.isPositive() and lmb_sensor.isPositive()

if make_bullet:
	# I am making the bullet hole, w00t
	GameLogic.addActiveActuator(add_bullet_act, 1)
	obj.ebhole = 1

hou to copy only X and Y orientation from material ?

copy only x and y orientation? that doesn’t make any sense

[even though I wrote that code, being mostly taken from shoot_the_bunny.blend I don’t understand it entirely]

screenshot with problem:

It looks like your using the script for tracks from vechiles, you should consider using alternatives to python, like logic bricks. :slight_smile:

You could use the add object actuator, it works fairly well, what I would do is attached the keyboard key with a frenquency of 20 (could vary depending on how you want it) and have it attached to a add object actuator, or if it was A.I. that’s continously moving, you could replace the keyboard sensor with a always sensor, with the same, or similar frequency.

Hope I helped :wink:

you probably won’t need any python for that anyway, just make the added mesh orient [and place flat on the ground] by using the shadow features already in blender.

great idea!!!