0 votes

so ive been making fruit ninja because my school gave me the assigment to make fruit ninja and ive been getting this error that says invalid call. nonexistent function 'interpolate_property' in base 'Nil'. and i dont know how to fix it. heres the code where the error is from. plz help this is due monday

for orange splat:

extends Sprite

onready var splat = $splat
onready var fade = $fade

func _ready():
    randomize()


# warning-ignore:function_conflicts_variable
func splat():
    var r = rand_range(1, 360)
    self.rotate(r)
    splat.interpolate_property(self, "scale", Vector2(.2,.2),Vector2(1,1) ,.3,Tween.TRANS_QUAD) #this is the code giving the problem
    splat.start()
    fade()

# warning-ignore:function_conflicts_variable
func fade():
    fade.interpolate_property(self, "modulate", Color(1,1,1,1), Color(1,1,1,0), 10,Tween.TRANS_QUAD)
    fade.start()
func _on_fade_tween_all_completed():
    queue_free()

orange code:

extends RigidBody2D


onready var tween = $Tween
onready var collision = $CollisionShape2D
onready var orangebottom = preload("res://orangebottom.tscn")
onready var orangetop = preload("res://orangetop.tscn")
onready var splat = preload("res://orangesplat.tscn")
func _process(delta):
    #area.disabled = true
    collision.disabled = true

func _ready():
    set_gravity_scale(10)

func fly():
    var randomx = rand_range(550, 1000)
    var randomy = rand_range(600, 900)
    var r = rand_range(200, 300)
    rotation_degrees = r
    tween.interpolate_property($Sprite, "position", Vector2(0,0), Vector2(randomx, randomy), 1.5, Tween.TRANS_QUAD, Tween.EASE_OUT)
    tween.start()



func _on_Area2D_area_entered(area):
    var p = get_global_mouse_position()
    var ob = orangebottom.instance()
    var ot = orangetop.instance()
    var splats = splat.instance()
    splats.splat()
    get_parent().add_child(ot)
    get_parent().add_child(ob)
    get_parent().add_child(splats)
    ob.global_position = p
    ot.global_position = p
    splats.global_position = p
    self.queue_free()

Main world code:

extends Node2D


onready var orange = preload("res://orange.tscn")

#onready var fruits = [orange]
func _ready():
    $slice.hide()


# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
    if Input.is_action_just_pressed("click"):
        $slice.show()
    if Input.is_action_just_released("click"):
        $slice.hide()


func _on_Timer_timeout():
    var fruit = orange.instance() #fruits[randi() % fruits.size()]
    $spawnpoint.add_child(fruit)
    fruit.global_position = $spawnpoint.global_position
    fruit.fly()
    $Timer.start()
in Engine by (12 points)
edited by

I edited your post to fix the broken code you pasted. In future, hit the "code sample" button when pasting code and it will be formatted correctly.

There are three different places where you call interpolate_property(), but you didn't indicate where the error occurred.

Either way, that error means that what you're calling interpolate_property() on is null. So at least one of these is invalid:

onready var tween = $Tween
onready var splat = $splat
onready var fade = $fade

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.