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?
-
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$– Duarte Farrajota Ramos ♦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$– sodiumnitrateApr 19, 2018 at 20:10
1 Answer
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.
-
1$\begingroup$ I didn't know about drivers. Thanks for pointing this out! $\endgroup$ Apr 19, 2018 at 20:10