need help with this script in 2.49

cont = GameLogic.getCurrentController()
own = cont.owner

fired = cont.sensors["fire"].positive
ray = cont.sensors["ray"]

force = cont.actuators["force"]
if ray.positive:
 OBJECT = ray.getHitObject()
 if fired:
  pos = ray.getHitPosition()
  bullet = force.objectLastCreated

as you can see i bin trying to make the script for 2.49
but it not working

its for a shoot system

force is the add object

is good it adds the objects but not at the place where it should be

the ray is set to a property of the objects i should shoot at

what did i wronge

i try all posible options with the setPostition i use the( bullet.position = pos )

but that dont work and localPosition olso how do i fix this

anyway greets dr-mad

I do not think that this will work as the addObjectActuator will add the new object with the next logic frame.
ObjectLastCreated will return the object created at the last activation of the addObjectActuator which is likely not the object you want as it is not created at this time.

You can replace activate(force) by force.instantAddObject(). That adds the new object immediatly and you should be able to get the reference to this object with objectLastCreated as you already do.

Anyway I do not understand why you want to spawn the bullet at the hitpoint of the ray. Shouldn’t that better a bullet hole or a splatter?

every thing works with the old scripts but now its deprecated and now i try to fix this code to the new 2.49 with the old 2.48 then this script works;)

but now it dont because i only need the setPosition(pos) to the deprecated version

but how do i do that

the goal with this script is that i add a object and its directly put to the object with the ray is set to

and fire is mouseclick

The warnings describe what to replace.

object.setPosition(pos) -> object.position=pos

cont = GameLogic.getCurrentController()
own = cont.owner

fired = cont.sensors["fire"].positive
ray = cont.sensors["ray"]

#print dir(ray)

force = cont.actuators["force"]
if ray.positive:
	OBJECT = ray.hitObject
	if fired:
		pos = ray.hitPosition
		bullet = force.objectLastCreated
		bullet.position = pos

this should do the trick. to see everything you can access inside of ray just uncomment the line which starts with an #

i cannot find the property hitposition, but i think your sensor should have it. i just tested the script with an collision sensor, cause i dont know which one you used.
if hitPosition gives an error just check with print dir(ray) how it should be named.

thanks this works fine but i keep trying i came out with the same script eventiuly
but many thanks to every one that helps me you both helpt me alot

thanks and greets dr-mad

lol this is a script from a youtube tutorial on how to make an FPS, (though it seems you have tried to pass it on as your own, no problem with that though!) The guy who made this modeled it after Social’s bullet/ray script from his FPS_Template-1 .blend. However I think Social’s script is superior and I recomend trying to implement his rather than this one. Though both work well, I have tested both, Social’s creates many fewer problems and is easier to implement and build complexities over.

Good luck!