Notifications
Clear all

[Closed] Unknown property: "pos" is undefined… WTF?

I’m using a script-controller on the path-percentage of an object that has a path-constraint controller as its position. In the script I’d like to return the length of the path as a value (to calculate a speed):

len = self.pos.controller.path

But I get the error-message Unknown property: “pos” is undefined

Uhm, isn’t “pos.controller” the usual way to address the object’s position controller?

Edit:
It looks replacing “self” with the object’s actual name works. Guess I’ve got it wrong, as I though “self” was a placeholder for the object that the script-controller is assigned to. Is there a way to refer to the object itself, without entering its specific name?

4 Replies
1 Reply
(@diffx)
Joined: 11 months ago

Posts: 0

Are you sure the error message is not “– Unknown property: “pos” in undefined”?

You have to create the variable “self” in the script controller, and then assign the Node you want to use as “self” to it. It’s not a default variable in the script controller.

You’re right… it’s “in”.

Still, is there a way to retrieve the name of the object that actually carries the script-controller? I have a lot of objects that get this script, and I’d rather not edit every single script to include the respective object-name.

1 Reply
(@bobo)
Joined: 11 months ago

Posts: 0

There is, sort of, a way to discover it (see topic “‘This’ Local Variable in Scripted Controllers”), but what if the same controller is instanced among 100 objects? It is the SAME controller, so which of the 100 objects would it “see”?

No, the script-controller won’t be instanced, just copied (even if it comes down to simply copy pasting the code).