0
$\begingroup$

I'm working on a project and I need to get the position of an object (not necessarily by python code) and at the same time I need to know how I can check if the position is on a special point like (0,3,6) for example. How can I do that?

$\endgroup$
0
$\begingroup$

I actually found out now, if someone needs to know, this is how I get the positions:

import bge import GameLogic as g

cont = g.getCurrentController() own = cont.owner pos = own.position x = pos[0] y = pos[1] z = pos[2]

and this is how I check for them: if x = 3.0 and 2.5 and y == 3 and z == 2.5: print("The object has the coordinates (3.0|2.5|2.5)")

$\endgroup$
  • 1
    $\begingroup$ Equal checks are no good idea. Due to imprecision of the number representations the object might be very close. Better calculate the distance to the reference position and check if the distance is inside a certain range. $\endgroup$ – Monster Apr 11 '18 at 8:20

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.