0
$\begingroup$

I have my camera tracking an empty and copying its movements. i want the empty to move to a button when it is clicked on, but i dont want the empty to turn at all while moving. just move straight at the other object. I had some basic java "training" with Alice and there it would have been as easy as saying move towards object for some duration or move to an object, but looking up the right command in python is something im still struggling in. i can make the empty move in coordinates or face the object and then move, but thats not what im looking for. This is in the Game Engine and i was looking in game logic. (bge.logic)

$\endgroup$

1 Answer 1

1
$\begingroup$

I'll admit it has been years since I've done any coding with the bge. But I would suggest looking up vectors. Get the vector from your empty to the object Then set the magnitude of that vector. Something like this:

vectTo = empty.getVectTo(object)

vectTo.magnitude = 2.0

empty.position += vectTo`

Like I said its been years and I don't have blender convinent to test (im really not sure that will compile) but something to that effect should work.

$\endgroup$
1
  • $\begingroup$ oh and just to be clear. Setting the magnitude gives it its speed. Skipping that step would make it teleport right onto the button. you might what to have a variable speed. setting the magnitute to empty.getDistanceTo(object) might be helpful. Whatever you want to do $\endgroup$ Mar 18, 2017 at 7:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .