Ray sensor, but not hitPosition


I am trying to get a ray sensor to spawn an object…
Rather then adding the object at the hitPosition I would like to
spawn it at a set distance (maybe 20) from the owners worldPosition.

So far I have been able to make it add the object at a hitPosition…
But I don’t need to use a ray sensor… What would be the best
way to do this??

A ray sensor can’t spawn an object ;).

You can place an object wherever you want by setting its worldPosition or localPosition.
Set the “emitter object” at the location you want the new object appear.

If you do not need hitPosition you can skip the ray sensor.

Is matter of vector sum.

You need import mathutils.Vector

  1. Get the position of owner with v1 = owner.position
  2. Get the direction in front of your owner with v2 = getAxisVect([…]).
  3. Change the magnitude of v2 (to 20 for example).
  4. The point for spawn is v3 = v1 + v2.

Remember convert v1, v2 and v3 to Vector.

Thank you xaedro!!

This seems like a much better solution then what I was trying :smiley: