1
$\begingroup$

Suppose I have a cube and a sphere. I want to write a python script such that when I move the cube by a vector (x,y,z), the sphere also moves by the same vector. I want to be able to move the cube by hand, and have the sphere move automatically. I realize that I can do this by selecting both before moving, but I would like to accomplish this with code. Is this possible?

$\endgroup$
2
  • 1
    $\begingroup$ Does it really have to be with code? I mean there are a bunch of built in tools to accomplish this, like say parenting, constraints, setting up relations that are much easier. $\endgroup$ Apr 19, 2018 at 17:59
  • $\begingroup$ @DuarteFarrajotaRamos This is partly out of curiosity, and also partly due to a possible scenario in which I would have too many objects. $\endgroup$ Apr 19, 2018 at 20:10

1 Answer 1

1
$\begingroup$

You can use drivers to do this, or use a constraint. The constraint is probably the fastest option (performance-wise), as they are written in C.

If you want you can even add drivers or constraints via Python, in case you want to have scripted control over those.

$\endgroup$
1
  • 1
    $\begingroup$ I didn't know about drivers. Thanks for pointing this out! $\endgroup$ Apr 19, 2018 at 20:10

You must log in to answer this question.

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