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.

godotengine.org | Twitter

0 votes

On Android it can't preload a scene. It works on Windows.
Code:
Touchscreenbutton:

func _on_TouchScreenButton_pressed():
    hero.skill1android = true

hero:

func process_Android(delta):
        if(skill1android == true and skill1_Activated == true):
            skill1android = false
            skill1_Activated = false
            senpai()

func senpai():
    print("3")
    var senpai = preload("res://objects/senpai.scn").instance()
    var pos = get_pos()
    if(dir == "RIGHT"):
        pos.x = pos.x + 100
        pos.y = pos.y - 120
    else:
        pos.x = pos.x - 100
        pos.y = pos.y - 120
    senpai.set_pos(pos)
    get_node("../..").add_child(senpai)

Logcat:

I/godot   ( 3224): ERROR: start: Condition ' !scene ' is true. returned: false
I/godot   ( 3224):    At: main/main.cpp:1464.
I/godot   ( 3224): ERROR: load_interactive: Condition ' err!=OK ' is true. returned: Ref<ResourceInteractiveLoader>()
I/godot   ( 3224):    At: core/io/resource_format_binary.cpp:1081.
I/godot   ( 3224): ERROR: load: Method/Function Failed, returning: RES()
I/godot   ( 3224):    At: core/io/resource_loader.cpp:218.
I/godot   ( 3224): ERROR: poll: Method/Function Failed, returning: error
I/godot   ( 3224):    At: core/io/resource_format_binary.cpp:681.
I/godot   ( 3224): ERROR: load: Condition ' err!=OK ' is true. returned: RES()
I/godot   ( 3224):    At: core/io/resource_loader.cpp:142.
I/godot   ( 3224): ERROR: load: Method/Function Failed, returning: RES()
I/godot   ( 3224):    At: core/io/resource_loader.cpp:218.
I/godot   ( 3224): SCRIPT ERROR: GDScript::load_byte_code: Parse Error: Can't preload resource at path: res://objects/senpai.scn
I/godot   ( 3224):    At: res://scripts/hero.gdc:251.
I/godot   ( 3224): ERROR: load_byte_code: Method/Funct

It's strange that this code works:

var shot = preload("res://objects/spit.scn").instance()

I get the error right when starting the game. I did not click anything and the game didn't load yet.
How can I fix it? This time I installed the newest export templates...

in Engine by (66 points)

did you check if senpai.scn file exists under assets/objects/ in APK?
The filename is correct senpai.scn, not Senpai.scn?

An old project of mine used preloading just fine on Android, but I had the scene preload into a member variable instead of in a method. Maybe try that...

@volzhs the filename is correct.
@batmanasb nothing changed.
Also, if I use preload("res://objects/spit.scn") instead of preload("res://objects/senpai.scn"), I don't get an error. So the problem is the senpai.scn
But why?

1 Answer

+3 votes
Best answer

I fixed it. The problem was, that I used the letter รถ in the name of a sprite.

by (66 points)
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.