1
\$\begingroup\$

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():
    add_child(tween)

    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()
\$\endgroup\$
2
  • \$\begingroup\$ 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? \$\endgroup\$
    – rcorre
    Commented Dec 9, 2019 at 13:20
  • \$\begingroup\$ Or, more importantly, what kind of object is parent? Are we talking about 2D or 3D? \$\endgroup\$
    – rcorre
    Commented Dec 9, 2019 at 13:21

2 Answers 2

2
\$\begingroup\$

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.

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

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

Child.gd

extends Node2D

onready var parent = $"../"
onready var tween = Tween.new()
onready var target_rotation = parent.rotation

func _ready():
    add_child(tween)
    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()

enter image description here

\$\endgroup\$

You must log in to answer this question.

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