From 2fea13f1a841a30ddf6ea193cc228e600e27fdec Mon Sep 17 00:00:00 2001 From: RhapsodyInGeek <44485952+RhapsodyInGeek@users.noreply.github.com> Date: Sat, 23 Sep 2023 00:11:09 -0400 Subject: [PATCH] Added support for Node2D and Control derived entities I realized if you somehow decided to set up a Node2D or Control as an entity you'd end up with an error trying to apply a Vector3 value to a Vector2 property. Instead of blocking this possibility, I added a check to allow for Vector2 compatibility. In Trenchbroom you position the 2D entity from the top down view. When built in Godot, the entity will be positioned according to the X and -Y origin values, eg: Vector3(64, -64, -1268) becomes Vector2(64, 64). This will allow mappers to add things like per map UI elements or screen effects without needing to anchor them to a Node3D. --- addons/qodot/src/nodes/qodot_map.gd | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/addons/qodot/src/nodes/qodot_map.gd b/addons/qodot/src/nodes/qodot_map.gd index 3af8f1e..0aac1b4 100644 --- a/addons/qodot/src/nodes/qodot_map.gd +++ b/addons/qodot/src/nodes/qodot_map.gd @@ -478,10 +478,15 @@ func build_entity_nodes() -> Array: var origin_comps = properties['origin'].split(' ') var origin_vec = Vector3(origin_comps[1].to_float(), origin_comps[2].to_float(), origin_comps[0].to_float()) if "position" in node: - node.position = origin_vec / inverse_scale_factor + if node.position is Vector3: + node.position = origin_vec / inverse_scale_factor + elif node.position is Vector2: + node.position = Vector2(origin_vec.z, -origin_vec.y) else: if entity_idx != 0 and "position" in node: - node.position = entity_dict['center'] / inverse_scale_factor + if node.position is Vector3: + print(entity_dict['center']) + node.position = entity_dict['center'] / inverse_scale_factor entity_nodes.append(node)