Simple (non python) assign location

Yes I have googled.

This seems really easy… how do I assign an object so that when it touches a certain material it changes location to X,Y,Z (world coordinates).

I have tried “property” > “assign” but using “LocX” and a number doesn’t seem to do anything. Maybe it’s called something else?

Well, its really simple with python

Just replace the X Y Z with the loc’s.

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

space = cont.getSensor("sensor")
pos = [X, Y, Z]

if space.isPositive():

Thanks for the input.

The reason I specified non python is that I am being asked to help out at holiday programmes, hosted miles away, with lots of students expecting to get started in the BGE. Aside from the high likelihood of turning up to find Blender installed without python support (believe me I’ve seen some cr*p installs from school lab technicians), I really don’t want to have to rely on students typing out lots of code… there’s too much room for syntax typing errors let alone the complexity of Blender in the first place. With two dozen young students, I’m thinking just logic bricks is plenty enough to learn and actually succeeding is important, so please let’s not get into the “python is good for them” argument… I really don’t want to go that route; learning python is for later.

…surely there’s a simple actuator which can simply assign world XY and Z coordinates? Also, if I use this to make the main player

Ha my bad. Anyway, you could use constraints, that works (Just finished testing)

I’d be interested in seeing your constraint solution.

So far, I reckon I can do it with a motion > LocXYZ movement… it’s not ideal in that it repels character to a given destination (relative to their initial position) as opposed to “setting” absolute (non relative) coordinates.

What I was going to use this for is the main character… when they leave a room on the left, I want to reset their position so they are entering the next scene from the right hand side, and have this possible in rooms which may have several doorways (dungeon labyrinth adventure). Unfortunately, there’s another problem. On changing scenes the LocXYZ seems to reset, regardless of using a common linked main character. (the player)

Ultimately I want to make the students a simple (for them kind of simple) turial where they make a set of dungeon rooms with booby traps etc. Repositioning each scene is important to make the character enter from the correct direction etc.

Sounds like an interesting idea.

Anyway, heres the constraint thing.


Test.blend (145 KB)

Thank you for that file. I’ve had a bit of a play with it and it certainly looks to be the best solution so far. I thought it would have locked the character into place, but no… they can still move around.

The main problem now is with changing scenes (hit S key in game attached)… Blender resets the positions of everything even though they are linked. Any idea on how to preserve continuity of movement from scene to scene?


Constraint_moveTest.blend (37.7 KB)

yeah, just turn on true lvl triggering on the movement keys. It should work then.

You don’t need a Python install for object.position.

Only if you’re importing things like time, random, or other modules will you need python installed. Everything else (GameLogic) is in modules within Blender.


Have tried this (it’s the first button on the keyboard press controls)… when pushing S to move to level 2, the character still resets position.

Unless I am understanding you wrong this should work.

Edit: I understand now, and as far as I know you cant do that without python. (unless I get a brainstorm…)


Constraint_moveTest.blend (149 KB)

Yeah, that’s not working for me. You see, when the player hits “s” the scene switches to scene 2… when it does this, the box resets its position. I want it to remain where it was on scene 1.

This will make it so I can work out how to reposition the player so they go out one way, and come in the opposite entrance on the next level.

Whew, found it. This does something like what you want, but with python.

Thanks, it’s very clever but I’m thinking a bit over the head of kids coming to the course and just wanting their character to walk from one scene into another.

…surely there must be a simple way of preserving the position of a linked object through the layers it’s linked to?

Glad to see that somebody found that to be useful… I made it like 2 years ago. This method used messages… which honestly are a kind of roundabout way of doing it. This can be done much more simply, though I think messages might be more efficient?

Without Python… kinda/sorta/not really. You can have scene duplicates with each scene depicting a certain starting location (the character would be in different places). For example, scene 1 would have to be duplicated any number of times - once for the initial location and again for the location of each of the “doors”. It’s not a great way of doing it…

However, you most certainly can’t preserve things like velocity from scene to scene without Python.

What exactly are you trying to demo for these kids? Try to stick with simplicity - multiple scenes aren’t really necessary for basic games.


Well, I’ve played a bit and have now done it without Python, although yes, it’s kind of complicated in terms of the number of logic blocks, and there is room for improvement in areas.

It works by relying on the arrow key still being pressed while the new scene is entered. The “when appears” sensor is a timer for the first split second of entering a new scene, and when combined with a keypress, constraints (thanks Excalaberr) are used to reposition the character to be coming from that direction.

Once this is set up, the running in is automatic and students would only need to make new scene rooms, adding doors with material and specifying which materials trigger entrance to which rooms.


Constraint_moveTest3.blend (49.9 KB)