# How can I get the NodePath that points to the property, rotation, of the parent node?

The 2nd arg in interpolate_property takes a NodePath, but str of a path to a prop seems fine too. So I'd expect this to work:

var rotation_node_path = "/root/Main/Boid1/InitialRegion/Bird:rotation"

but I'm getting the error

ERROR: interpolate_property: Condition ' !prop_valid ' is true. returned: false

func lerp_rotation():

var rotation_node_path = str(parent.get_path()) + ":rotation"
var current = Math.smallest_equal_angle(parent.rotation)
var target = Math.smallest_equal_angle(target_rotation)
var duration = 1
print(current, ' ', target, ' ', rotation_node_path)

tween.interpolate_property(parent, rotation_node_path, current, target, 1, Tween.TRANS_LINEAR, Tween.EASE_IN_OUT)
tween.start()

• Adding some types might help. What is Math.smallest_equal_angle? I can't find that in the godot docs. What type of object are you running this in? Dec 9 '19 at 13:20
• Or, more importantly, what kind of object is parent? Are we talking about 2D or 3D? Dec 9 '19 at 13:21

It seems that Tween.interpolate_property does not look at the path before the resource. You should just pass the target node (parent) as the first argument, and a pure resource path as the second:

tween.interpolate(parent, ":rotation", ...)


I believe this stems from an of set_indexed in Object:

The trouble with supporting this with set/get_indexed directly is that they are defined in Object, and not in Node, and Object shouldn't really know about Node. Maybe the method could be overridden in Node, but this could have performance implications.

• Note that you can use a nested resource path, e.g. :texture:size, you just shouldn't try to pass a different node path. Dec 9 '19 at 13:42
• thanks. I didn't realize it's relative to the 1st arg, the target. "roation" is also valid there. Dec 10 '19 at 8:11
• see my answer to my own question that just focuses down my one issue Dec 10 '19 at 8:27

isolated & minimal project w/ solution: the triangle rotates counter-clockwise forever

Child.gd

extends Node2D

tween.start()
tween.connect("tween_completed", self, "_on_tween_tween_completed")
lerp_rotation()

func lerp_rotation():
var current = parent.rotation
target_rotation += -PI / 2
var duration = 1
print(current, ' ', target_rotation, ' ')

tween.interpolate_property(parent, "rotation", current, target_rotation, duration, Tween.TRANS_LINEAR, Tween.EASE_IN_OUT)

func _on_tween_tween_completed(object, key):
lerp_rotation()