I'm trying to get an object to scale with its distance to another object, so I can then link the driver to the rest of the 639 objects in the collection.


I need it to somehow refer to itself, rather than explicitly selecting the object, so that when I link the driver, each of the linked objects will scale individually with their own proximity to the sphere. The intention is for each of the hexagonal objects to scale down when the sphere gets close.

In this thread, one answer says that if Use Self is checked, I can do the distance measurement in the expression itself if I use Single Property and use the sphere's matrix.world as the Object, but matrix.world isn't accepted when I try this.

In addition, is there a way I can get the driver to control XYZ scale so I don't need to use 3 drivers?

If I'm going about this in the wrong way I don't mind restarting the project.

Thanks in advance.

Attaching my blend file as requested. In this file, the driver is working correctly, but that's by specifying icosphere.083 as Object 2. I need it to work by somehow referring to "self" or "this object", so I can link the driver to other objects and have it work per object.


  • $\begingroup$ Hello ! It's matrix_world and not matrix.world are you sure you used the correct expression ? $\endgroup$
    – Gorgious
    Dec 6, 2021 at 9:11
  • $\begingroup$ matrix_world is also not accepted in the path field: i.imgur.com/i1mOpJc.png $\endgroup$
    – Stage
    Dec 6, 2021 at 10:25
  • $\begingroup$ can u provide blend file? then i would check it out $\endgroup$
    – Chris
    Dec 6, 2021 at 10:27
  • $\begingroup$ I've added a link to the blend file in the OP. $\endgroup$
    – Stage
    Dec 6, 2021 at 10:37

2 Answers 2


I noticed in your file that you had had a go with Geometry Nodes.. so as a side-note, this would be a possible arrangement:

enter image description here

The Length of the 'Relative' (i.e. owner's Object-Space) Location of the Object Info target is the distance from the GN-modified object-origin to the target object-origin. You can use some function of that for object-level proximity effects:

enter image description here

  • 1
    $\begingroup$ Oh wow. I feel bad for Chris now. This actually suits me better than the script solution, because I can apply this to other things without feeling like I'm messing with powers beyond my ken. I hadn't fully tried to make it work with GNs, because I thought I'd need an individual GN for each hex. Now I love GNs even more than I already did. Thanks! I still need to learn scripting :P $\endgroup$
    – Stage
    Dec 6, 2021 at 14:41

you can use this script:

import bpy

# two sample functions
def calcDistance(object):
    location2 = bpy.context.scene.objects["AssaultSphere"].location
    print("loc2", location2)
    location1 = object.location
    print("loc1", location1)
    distance = (location2 - location1).length
    print(distance * 3)

    return distance

# Add functions defined in this script into the drivers namespace.
bpy.app.driver_namespace["calcDistance"] = calcDistance

driver settings:

enter image description here


enter image description here

  • $\begingroup$ That is excellent, and works very well. Thank you very much. I can understand most of the script, but it's beyond my ability to arbitrarily replicate. I knew this would end up with me having to learn Python, but didn't expect it so soon. $\endgroup$
    – Stage
    Dec 6, 2021 at 11:25
  • $\begingroup$ Glad I could help. $\endgroup$
    – Chris
    Dec 6, 2021 at 11:26
  • $\begingroup$ I just can say from my personal experience: you can do a lot just with Blender - but you can do a lot more with python…‼️👍🏻🤗 $\endgroup$
    – Chris
    Dec 6, 2021 at 11:28

You must log in to answer this question.

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