addobject using coordinate

hi guys,
it is possible to add an object in the bge scene using coordinate instead of using an existing object?
thx

edit: i mean using python

add=scene.addObject(“Object_name”,own,0)
add.worldPosition=(x,y,z)

Just use any object to add. You need one to run the code anyway.

yeah i know that code but instead of using own (in that case) to place the added object i wanted to add object using coordinates directly… something like this
add=scene.addObject(“Object_name”,[x,y,z],0)

You don’t need a spawn object to add the object, so just set the position after creating it. ( use the same name of the object you want to add for the second argument)

hum can you write an exanple code pls?

then end result is what matters, adding at a object and moving it, is the same as adding it at the position due to the game loop…

BluePrintRandom just gave you the code in the first reply…

yes but what i want to know, if its possible to add an object without that “own” in the code, what i need its to be able to add an object without using a spawn object’s reference if it is possible.

If I buy a cannon, or make a cannon, it is still a cannon.

it is not a duck.

then end result is what matters, adding at a object and moving it, is the same as adding it at the position due to the game loop…
-unknown mystic

What does it matter what location you use, you’ll be changing it the very same instant? You can use any object’s reference but own is quickest to refer to.

This is the only way unless you want to first make another spawner that spawns a spawn point first in it’s own origin and moves it to (x,y,z) where you want, and then runs a spawn script that spawns your object in that location. EHE.

hahaha ok, but assume i want to make that cannon, just to know how

Unless you want to go into Blender’s source and modify the add object command there, you’re going to have to use a reference object when adding objects.

What are you trying to do that you can’t use an object in addObject?

Simply :

OBJ = scene.addObject(hidden_OBJ, hidden_OBJ)
OBJ.worldPosition= Vector((x, y, z))

I didn’t think this would work, but in principle, the second argument is only used as a legacy implementation detail in my opinion, to access the transformation matrix of the object.

ok thank you