Nodragem / twin-stick-shooter-starter-kit

A small prototype to learn implementing basic gameplay mechanics in Godot Engine
Creative Commons Zero v1.0 Universal
222 stars 26 forks source link

Collisions and destructibles #3

Open biox86 opened 4 months ago

biox86 commented 4 months ago

I just tried the project and took a look at the various nodes but I can't see any collision for the fornitures and any kind of destruction like in the preview video. Is the video recorded with a more advanced version than the one in the repo or am I missing something?

Anyway, thanks for this template, it's gonna be a great use case study!

Nodragem commented 4 months ago

Normally the master branch has the destructible pieces of furniture.

If you open level2.tscn, you should see the collision boxes of all the objects, like here: image

Here I selected one of the cube, if you want to see more of what is being the scene, you would right-click and select Editable Children and you should see the rigid body and collision nodes: image

I add these nodes and set them up during the import (i.e. post_import callback), hence if you drag and drop the .glft file (res://assets/prototype_bits/Cube_Prototype_Small.gltf) in a scene, it will immediately appears with the nodes that makes it destructible.

The post_import function is in res://tools/automation/import_destrutible.gd if you want to have a look at it.

biox86 commented 4 months ago

Ok, I did a fresh clone of the repository, but at first launch Godot tells me that res://tools/automation/import_destrutible.gd has parse errors.

Screenshot 2024-06-06 alle 16 39 58

The strange part is that if I open the file it has no errors at all.

Reopening the project doesn't give the error anymore, but level1 and level2 still have no collision nor they are generated while importing any gltf.

I also cannot see where the file import_destrutible.gd should be called. Should it be an autoload that maybe has been removed be the parse error during the first open?

I forgot to tell, I'm Godot 4.3 beta1 on OSX.

Thanks in advance for your time.

biox86 commented 4 months ago

I'll attach one more image to see better there no collisions are generated.

Screenshot 2024-06-06 alle 16 52 16
Nodragem commented 3 months ago

Hello! Thank you for the useful screenshots.

I had a look at the problem this morning, I cloned the project on another laptop, using Godot 4 beta1, and I successfully replicated your issue and found a walk around 😃 !

Issue

The issue is due to using a helper class CollisionTool (to keep my code organised) in import_destructible.gd. It looks like a Godot bug, which I will report. Basically, on the first start of the project, Godot seems to try importing the scenes before to have registered the static functions. Hence, it flags import_destructible.gd has containing a Parsing Error, which is to reference a non-existing CollisionTool class. See the 2 first lines in red below:

image(1)

Walk Around

For now, you will need to follow this steps:

Now you should see in the Output tab that the destructible script was added to many objects. If you open level2.tscn you should see that the furniture are now Node3D with a script.

Meanwhile

I will report the issue to Godot repo, and I might remove CollisionTool for now (and have a slightly less organise code).

biox86 commented 3 months ago

Great, I just tried to reimport the assets and now everything works as expected.

I started digging into the code: first of all congrats, it's pretty neat! Just looked how importing and setup collision works and it's really useful especially in the first phases. Now I'll continue taking a look and eventually open another discussion with a few things.

At the moment I just have a doubt about a queue_free ordering choice and I found an unused signal definition ( probably you changed something and you forgot that ). Anyhow I prefer to look at everything, so if there's a few little things It could be better to discuss them in a single place instead 10.

Thanks again for the super fast answer! Glad to have been useful ( and sorry, I've been stupid, I could have copied the entire output on first launch but I hadn't thought about that... darn ).

Nodragem commented 3 months ago

No worries, a full review of the code and how to improve it is really welcome. It is a project for me to learn how to use the engine and hopefully be used by others as a working, although not perfect, example.

NeonfireStudio commented 3 months ago

Why showing an error in extends ConditionLeaf

biox86 commented 3 months ago

You need to install beehave. Just click on assets, search for beehave, click download and reload the project.

BitterArtist commented 3 months ago

When I run the game in the Godot editor the enemy behavior works fine(Beehave plugin is installed and enabled), but when I export a Windows executable and run the game directly the behavior is not working - they just stand around and never chase or attack the player. Do I have to specifically enable the plugin when exporting?

Nodragem commented 3 months ago

Hello! sorry for the late reply. I just tried to export the project to a Windows executable and it seems to work. From reading about it, it seems that if the export mode is set to "export all ressources in the project", it will export the add-ons as well: image

Can I ask you to open a separate issue if this is still happening?

BitterArtist commented 3 months ago

I think it was an import issue, because I didn't really change anything but I re-imported the project and it's working properly now.