Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export build crashes when using CreatureGodot node #16

Open
sampenland opened this issue Oct 25, 2019 · 10 comments
Open

Export build crashes when using CreatureGodot node #16

sampenland opened this issue Oct 25, 2019 · 10 comments

Comments

@sampenland
Copy link

Godot Version: 3.1.1 Stable source (compiled with creaturegodot folder from creaturegodot3 folder)

Everything works fine in the editor! It's an awesome product, Creature, and I really want to use it. The guy I made looks great in the editor - walks, jumps, etc. but when I export the game (using a custom compiled template as required) everything works fine until I get to my scene with a CreatureGodot node then the game crashes without an error. I've done debug templates and still no error printed in Godot, so I'm a little lost on what is causing the issue.

I've read that *.json files could be the problem so I added them to be included in the Godot export. Still no luck.

I see on the readme.md that you say Godot 3.0, does this mean 3.0 must be used or is 3.1.1 okay?

Any help would be great! Even if it's just pointing me to the code of this project and changing/updating something. I know a little c++ (kinda). Without an error from Godot, it's hard to determine what is going on to fix the issue.

@kestrelm
Copy link
Owner

Hello,
Sorry there is not enough detail in your description to enable any sort of reasonable solution.
If something crashes, you hopefully should be able to get a stack trace at the C++ level out of it. Then it should tell you which line and what function it crashed on. You might want to start from there. Thanks

@sampenland
Copy link
Author

I'm having trouble getting a stack trace from Godot. When I get it, I'll update this.

Just to make sure, Creature should work with Godot-3.1.1 stable, right?

Also, I'm sorry if this wasn't the place to post this. Wasn't sure where else to ask.

@kestrelm
Copy link
Owner

Hello,

Yes I have it built and running in it. At least as far as I can tell.

@sampenland
Copy link
Author

Ok. Thanks. I'll continue my search on how to get Godot to produce an error for me.

@sampenland
Copy link
Author

I narrowed down the problem a bit.

Using your Godot3Demo with the owl scene. You can run in editor and it works. You can build .exe in res:// folder and it works, but if you build into a "Build" folder the project does exactly what my project does - crashes with no error.

If you move the owl.json file into the Build folder then it works. I believe this is the issue I saw on another issue.

I have in my export to include json files in export. So, it seems that the .exe cannot find the json file inside the pck file.

@kestrelm
Copy link
Owner

Ah yes, this has something to do with how Godot puts the asset files. The plugin itself probably does not decide where to get the files. So it could be an issue with Godot's asset path system...

@sampenland
Copy link
Author

I got everything working for a Windows build by moving things around in kinda a ugly but working way. I am now trying to export to Android. I'm having an issue with it. Have you tested exporting to Android?

@kestrelm
Copy link
Owner

Hello,
No I have not tried on Android. However I am providing some reference code for you, it might be useful in your current endevour .
Take a look at:
https://github.com/kestrelm/Creature_Godot/blob/master/creaturegodot3/creaturegodot/creaturegodot.cpp

In particular:

bool CreatureGodot::load_json(const String filename_in) { auto global_path = ProjectSettings::get_singleton()->globalize_path(filename_in); #ifdef _CREATURE_DEBUG std::cout<<"CreatureGodot::load_json() - Loading file: "<<global_path.utf8()<<std::endl; #endif std::string load_filename(global_path.utf8());

These are lines 99 to 105. Notice where it gets the filename from ( the input parameter filename_in ). The filename itself is set from:

void CreatureGodot::set_asset_filename(String filename_in) { auto retval = load_json(filename_in);

at line 482. This can be useful for you to customize and perhaps point the assets to some place you find more appropriate for your project.

@alperc84
Copy link
Contributor

alperc84 commented Nov 29, 2019

@kestrelm maybe you can update your tutorial with this way. Because using res:// in android impossible and using user:// works for windows too. @sampenland
My Godot 3.1.1 builds works in windows 10 and android without any problem. Simply, I am adding json file to my build and copying it to user:// folder in runtime and using it from user:// (not res://) Follow this:

Go export->resource settings in Godot and add *.json to filters to export non-resource files (this will add your json file to res://) I mean you adding your json file to your build with this way.
But we need to export json file to user:// directory for access in correct way.

Create a root node (2d scene) attach a script for it:

extends Node2D

func _ready():
	var dir = Directory.new()
	dir.copy("res://some.json","user://some.json")

This script will copy your json from res:// to user:// in runtime (you can add some error handling, check file if exist or something like that if you want)

Now you can add creaturegodot node to your root node and use user://some.json instead of res://some.json in Assetfilename.

When you launch the game your json file will be copied to user:// and will work without any problem in android and windows builds (probably for mac and linux too). Plus, you don't have to put your json file next to your final exe. Because json file in your game already now.

You will find you json in this directory when you launch your game if you did the things correctly.
C:\Users{username}\AppData\Roaming\Godot\app_userdata{projectname}\some.json
I don't know android user:// directory location but it's working in same way.

IMPORTANT: Do not forget to enable Write External Storage permission in your android export settings ->Permissions (no write permission = no json)

My English is not perfect. If you feel like I am talking robotic and rude, I am sorry about it. Just trying to help :). If needed I can make a small example project.

@MelimeliDev
Copy link

Hello, is there a way to fix the issue here? So that the required files do not need to be copied to user:// and just use the files in res:// instead.

I plan on using this for my game, and it seems very bloated to copy a lot of animation files.

Would this be fixed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants