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
$\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.

|improve this answer|||||
$\endgroup$
  • $\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$ – Kyle Storey Mar 18 '17 at 7:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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