Setting location

Is it possible to set an object to a specific point in space using logic bricks?

Well, in python, it is very simple.

just use getPosition()
and setPosition()

for instance:


import GameLogic as GL
cont = GL.getCurrentController()
owner = cont.getOwner()
obj = GL.getCurrentScene().getObjectList()
player = obj['OBPlayer']
player.setPosition([xpos, ypos, zpos])

considering your object is called ‘Player’ and you replace ‘xpos, ypos, zpos’ with respective values. just connect an ‘Always’ sensor to a ‘Python’ controller with the script in it.

Hope that helps!

Túrin

You can also use IPOs, if you’re afraid of Python. Just set your character’s initial position as frame one (so that he starts there correctly and doesn’t get reset), and then set the position that you want to move your character as frame 2. Then just use an IPO actuator to set your character’s position. Make sure that it’s not constantly playing, or you’ll have issues.

Not afraid of python, just exploring the boundaries of the bricks.

I appreciate your suggestion. But let me clarify, I want to set an object at a specific place in global coordinates. It appears the only way is through python. Which is okay, that’s why I’m exploring.

Thank you, Turin. I was already familiar with this method (but I appreciate you posting). I was interested in whether it could be done using logic bricks. I don’t see a way.

Isn’t an IPO location a specific spot in global coordinates? Is that spot going to change based on what’s happening in the scene? If not, IPOs work fine.

Attachments

setLocationLogicbricks.blend (193 KB)

You’re right, thank you! Great example!