aligning a entity ot the normal of a collision

Blitz3D Forums/Blitz3D Programming/aligning a entity ot the normal of a collision

pick=LinePick(EntityX(weapon,1),EntityY(weapon,1),EntityZ(weapon,1),TFormedX(),TFormedY(),TFormedZ())
if pick
 setdecal()
endif

Function SetDecal()
	nx#=0
	ny#=0
	nz#=0
	nx=nx+PickedNX()
	ny=ny+PickedNY()
	nz=nz+PickedNZ()
	x#=x#+PickedX()
	y#=y#+PickedY()
	z#=z#+PickedZ()
	s.decal=New decal
	s\ent=CopyEntity(decalsprite)
	s\life#=decal_stay
	RotateSprite s\ent,Rand(360)
	temp#=.05+Rnd#(-.01,.01)
	ScaleSprite s\ent,temp#,temp#
	PositionEntity s\ent,x,y,z
	AlignToVector s\ent,-nx,-ny,-nz,0
	MoveEntity s\ent,0,0,-0.0075
	Return s\ent
End Function

------------------------------
This should do the job. at least it does for me ;)