What I need is for him to check for the first ray sensor that detects no obstructions and then change his position 15 or so units in that direction.
I wrote a script that works swimmingly except that I tried using self.localPosition[0] += 15 for example to get him to move.
Well, he moves but no matter which way he is facing self.localPosition[0] += 15 always sends him the same world direction.
so if he faces east and an enemy approaches from the east, he will move himself west. but if he faces north and an enemy approaches from the north he will still teleport west.
is there a way to have him move in essence backward from his local orientation no matter the aforementioned orientation?
“local” and “world” positional identifiers are only for seperating children parameters from global parameters. The “local” position will always align with the global orientation, which means that the way you’re doing it won’t work.
Honestly, the way I’d do it is, have an empty attached to the character (or some other target object, maybe a mouse reticle that defines exactly where to teleport to?) at that spot, and set your character’s world position to that object’s world position when you teleport. (With a tap sensor, of course, otherwise you’d be going to the next spot over and over instantly forever!)
In addition to what pgi said, if you want to move forward in a direction based on his orientation, then you’d have to use the worldOrientation property for this purpose. But his answer probably is what you need (though end can just be other_position.copy() rather than making an entirely new vector out of its components if it’s already in Vector form).