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

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

# 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)
func _on_fade_tween_all_completed():

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

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)

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

Main world code:

extends Node2D

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

#onready var fruits = [orange]
func _ready():

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

func _on_Timer_timeout():
    var fruit = orange.instance() #fruits[randi() % fruits.size()]
    fruit.global_position = $spawnpoint.global_position
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.