The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates. | Twitter

+1 vote

On android I get strange errors:

I/godot   ( 1575): SCRIPT ERROR: _process: Invalid operands 'Nil' and 'int' in operator '+'.
I/godot   ( 1575):    At: res://scripts/hero.gdc:75.

And other errors which are caused by because everything is nil.
On Windows everything works fine!!

Here is a part of the

extends KinematicBody2D

var dir = "RIGHT"
var lefttexture = load('res://sprites/hero_M_Left.tex')
var righttexture = load('res://sprites/hero_M_Right.tex')
export var WALK_SPEED = 200.0
export var GRAVITY = 200.0
export var JUMP_HEIGHT = 200.0
export var DAMAGE_MULTIPLIER = 1.0
export var LEVEL = 1
var velocity = Vector2()
var scale = Vector2()
var left = false
var right = false
var up = false
var attack = false
var attacking = false
var isPressed = false
onready var sprite = Sprite
onready var upbutton = TouchScreenButton
onready var leftbutton = TouchScreenButton
onready var rightbutton = TouchScreenButton
onready var JumpingArea = Area2D
onready var level_Label = RichTextLabel
onready var Spit = RigidBody2D
onready var SpitArea = Area2D
var jumping = false
var temp_Health_regen = 0
var Health = 100
var max_Health = 100
var experience = 0
var max_Experience = 10
var regeneration = 0.01
var hitting = false
var hitting_Damage = 0
var canSpit = true
var timer = 0
var damagetimer = 0
var canBeDamaged = true

func respawn():
    self.set_pos(Vector2(300, 291))
    jumping = false
    Health = max_Health
    attack = false
    attacking = false
func _on_Area2D_body_enter( body ):
    print("Entered Area2D with body ", body)
func _on_Area2D_body_exit( body ):
    print("Exited Area2D with body ", body)

func _ready():

    self.set_meta("hero", true)
    sprite = get_node("/root/Node/Node/Hero/HeroTexture")
    upbutton = get_node("/root/Node/CanvasLayer/Control/Up")
    leftbutton = get_node("/root/Node/CanvasLayer/Control 2/Left")
    rightbutton = get_node("/root/Node/CanvasLayer/Control 3/Right")
    JumpingArea = get_node("/root/Node/Node/Hero/JumpingArea")
    Spit = get_node("/root/Node/Node/Spit")
    SpitArea = get_node("/root/Node/Node/Spit/spitarea")
    level_Label = get_node("/root/Node/CanvasLayer/Control 4/Level_Container/Level_Label")


func _process(delta):
    timer = timer+1
    if(timer >= 60 ): #THIS IS LINE 75
        timer = 0
    if(canBeDamaged == false):
        damagetimer = damagetimer+1
        if(damagetimer >= 20):
            canBeDamaged = true
            damagetimer = 0
    if(experience >= max_Experience):
        experience = 0
        LEVEL = LEVEL+1
        max_Experience = max_Experience*(LEVEL/1.75)
    if(Health < max_Health):
        temp_Health_regen = temp_Health_regen+regeneration
    if(temp_Health_regen >= 1):
        Health = Health+temp_Health_regen
        temp_Health_regen = 0
    if(self.get_pos().y >=1000):
    if(Health <= 0):
    if(OS.get_name() == "Android"):

Why do I get this error? I mean timer isn't null:

var timer = 0

I'm using the latest nightly of the Engine (2.1 alpha)

in Engine by (66 points)
edited by

does the error come up at start?
isn't hero dead?

The error comes up at start and always continously spams the logcat console. The hero is not dead. Because it's null I can't even move him. Variables like 'dir' are not null.
It happens only in Other scripts like the enemy script are working.

That sounds weird.
But I can't guess what the problem is without testing myself.
Can you make a sample project can reproduce this?

I can't reproduce it. Can I pm you the link somewhere?

volzhs at

1 Answer

0 votes
Best answer

Okay this is very strange but I solved the problem: I created a new project and I copied all files from the old project into the new project. I think I got the problem because I upgraded from the release to the alpha version.

by (66 points)

good to hear. :)

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 Frequently asked questions and 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 [email protected] with your username.