Giter Club home page Giter Club logo

godot-ldtk-importer's People

Contributors

heygleeson avatar theneikos avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

godot-ldtk-importer's Issues

Importing LDTK info on post import script

I would like to be able to get info, like in grid names. Let's say I have an int grid layer

image

In the generated tileset8x8.res I can see this

image

I would like to be able to map these names to the atlas source id. Why? Let's say I collide with a tile and I want to know which sound to emit based on the material, that I mapped in ldtk to a int in the intgrid layer. But I can't get any of that info using the post import scripts.

Would it be possible to get more info in the level or tileset post import?

Importing Tiles On Top Of Each Other

Is there currently a way to import 2 tiles that are on the same layer and on top of each other??

My LDtK preview looks like this
image

But the level on Godot looks like this
image

You can see the that green moss blocks the tile underneeth

Seperating levels into individuals scenes

I want to procedurally generate a world for my game where the level order is randomly generated and to do that, I need to randomly instantiate the levels. But, as far as I know, there is no way to do that currently.

How to import collisions?

Hi I'm pretty new in the Godot and LDtk i could not get how to import a collision?
I successfully imported ldtk file, it has 2 layers but do not have any mentions of collisions itself.

Thank you in advance.

Is there a way to import "level.ldtkl" files?

I'm new to game development and LDtk. I want to try implementing lazy loading to optimize performance. I also want to try storing a lot of levels in a GridVania world that I can use as a pool to generate a dungeon layout.

It seems I have to load every level at once to utilize an imported world.ldtk scene. But LDtk has the option to export individual level files. Is there a way I can utilize these files or implement some other logic so I can achieve lazy loading, etc.?

The best thing I could think of is injecting a VisibleOnScreenEnabler2D underneath every level node, but that seems very janky and still requires the loading of every level at once.

Add Children to Entities in Post Import Script? (more of a question than issue)

This is more of a question than an issue, so apologies for the out of place issue.

I'm using the Post-Import script for the EntityLayers to replace entity layers with my own custom BoundingBox Scene (based on an Area2D which needs a collision shape child). That is working correctly.

However, I would like to add a CollisionShape2D as a child to that BoundingBox node and have both appear in the final import. Currently, the BoundingBox appears in the final world, but does not have any children.

I believe this is from the owner not being set, but I am not sure how to set the owner of the CollisionShape2D correctly in the post-import script. I thought this would be handled by code that is run later, but it appears not.

Here's my current import script:

@tool

## Entity Post Import Example, showcasing how to handle EntityRefs.

const Util = preload("res://addons/ldtk-importer/src/util/util.gd")
const boxScene = preload("res://scenes/bounding_box.tscn")

func post_import(entity_layer: LDTKEntityLayer) -> LDTKEntityLayer:
	var entities: Array = entity_layer.entities
	for entity in entities:
		# Create entity node (simple example)
		var bounding_box = boxScene.instantiate()
		bounding_box.position = entity.position

                # Create RectangleShape2D from entity shape
		var new_rect: RectangleShape2D = RectangleShape2D.new()
		new_rect.size = entity.size

                # Create CollisionShape2D with shape
		var new_collision_shape: CollisionShape2D = CollisionShape2D.new()
		new_collision_shape.position = entity.position
		new_collision_shape.shape = new_rect
		
                # Add CollisionShape2D as child of BoundingBox (this is what is not working)
		bounding_box.add_child(new_collision_shape)
		new_collision_shape.owner = bounding_box # This doesn't seem to do anything
		
		entity_layer.add_child(bounding_box)
		
		# Update 'iid' to reference this entity node
		Util.update_instance_reference(entity.iid, bounding_box)

		# Add unresolved reference (e.g. EntityRef field)
		if "Entity_ref" in entity.fields:
			var ref = entity.fields.Entity_ref
			if ref != null:
				bounding_box.ref = ref
				print("adding unresolved ref")
				Util.add_unresolved_reference(bounding_box, "ref")

	return entity_layer

Am I missing an obvious addition that makes the owner get set later on in the import process?

How to use Y-Sort?

Normally you have to enable Y-Sorting on a per-layer basis on the Tilemap - but since the Tilemap is created via import and can't be edited, is there a different way of accomplishing this?

Not an issue but more a question (Entities)

This is most likely better with Github discussions but I was curious what a workflow looks like with entities.

The two avenues I can think of are using the hook for entities to instantiate scenes based on the entity date.
The challenges are... the JSON data is untyped because GODOT arrays are untyped and a bit more of a hassle

The other avenue is using the Placeholder Entities, grab a reference the entity, then at runtime, copy all the fields and then destroy it.
The downside is the overhead of needing to copy and destroy each placeholder.

Incorrect grid_w calculation

I think you need to round up here. I am getting a off-by-1 error here and ceili seems to fix it.
https://github.com/heygleeson/godot-ldtk-importer/blob/f07f927e1ba82a326a3fb94f7e144a1fbd920d1e/addons/ldtk-importer/src/tileset.gd#L114C22-L115

Something like:

var grid_w: int = ceili((definition.pxWid - margin) / (tile_size + separation))
var grid_h: int = ceili((definition.pxHei - margin) / (tile_size + separation))

I'm not entirely sure how the LDtk structure works, but looking at the file, you may just want to use the fields "__cWid" and "__cHei" rather than trying to calculate it from the pixel width.

In my case, __cWid is 31, but because the grid_w calc is hard rounding down, it ignores the last column and is getting 30 instead.

Entities spawned during the entities post-import script are unpacked

When placing Godot scenes during the entities post-import script; the scenes are unpacked and lose their 'prefab' status in the editor. This is due to the recursive set owner setting all sub nodes (including spawned sub-scenes and all of their children) to the world node.

for node in level.get_children():
	Util.recursive_set_owner(node, world)

The intended effect is that all of the scenes which are spawned during post-import scripts are kept as sub-scenes with their 'Open in Editor' icon in tact. This keeps the reference to the scene and I can update all spawned scenes by just editing the scene for the entity.

image

A fix that I use is to place the post-import script for entities after the recursive set owner and set the owner of the sub-scene root node to the layer by hand. However; this is probably not workable as a general fix.

if (Util.options.entities_post_import):
var layers = level.get_children()
for layer in layers:
	if not layer is LDTKEntityLayer:
		continue

	if (Util.options.verbose_output):
		var entityLayerName = layer.get_parent().name + "." + layer.name
		print("\n::POST-IMPORT ENTITIES: ", entityLayerName)

What probably needs to happen is that when traversing the tree to set the owners; spawned sub-scenes in post-import scripts only have their root node set the owner of; but not their children.

Simplify tile flipping

I think it might be possible to simplify the code that flips tiles since tile flipping was added back to Godot 4.2 (without the need to create alternative tiles).

Can't see tileset in Godot

As I import and open the .ldtk file into Godot, the editor shows a blank scene. A 16x16 tileset.res file in created, but there is no texture assigned to it. I can't find instructions on hold to make tileset textures work.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.