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

Connecting Objects #707

Closed
IcemarkUK opened this issue Jul 29, 2014 · 28 comments
Closed

Connecting Objects #707

IcemarkUK opened this issue Jul 29, 2014 · 28 comments
Labels
feature It's a feature, not a bug.
Milestone

Comments

@IcemarkUK
Copy link

Currently looking through Tiled to see if I can use it for a couple of my projects. I can get round most of my issues ( default properties on objects, easily creating objects of type ), but the one feature that would find very useful is the ability to connect two objects.

Sometimes you want to have a relationship between two objects, and you would like that relationship to by sticky. So it would be handy if you could select a connecting tool ( some combination of shift/alt/ctrl and select of object ) and drag a connection from one object to another.

You could have multiple connections from and to objects.

A connecting line would be visible on screen.

A connecting line could have name and properties to allow definition of the relationship.

Deleting an object would remove all connections on other objects.

For now workarounds are to place the name of an object into the properties of another object. But a visual process would be much nicer. I have looked at using the Polyline but not being able to resize is a pain, and not sticking to an object when you move it is more the real problem. Being able to meld the Polyline to objects would be a solution.

screen-shot-2014-07-29-at-17 58 27

screen-shot-2014-07-29-at-17 54

@bjorn bjorn added the Feature label Jul 29, 2014
@bjorn
Copy link
Member

bjorn commented Jul 29, 2014

This suggestion has come up before but you have thought it through and illustrated it really well. Thanks!

When this gets implemented, care should also be taken that these connections are a good fit for defining joints between bodies for games using a physics library.

Unfortunately it's impossible for me to say when I might get around to implementing this. In my current situation, unless somebody does a pull request or sponsors the feature it is unlikely to happen.

@IcemarkUK
Copy link
Author

What's involved in sponsoring a feature?

@bjorn
Copy link
Member

bjorn commented Jul 29, 2014

I was somewhat afraid you would ask me that, since it's a busy time at work and at home so it's a little bit tricky to set time aside right now. Yet, the idea is that we agree on a fair compensation for the time I expect to spend on it and then I will prioritize it over other activities. If you're interested, please contact me privately about this at [email protected] and include information about when you would need this feature to be done.

@naiello
Copy link

naiello commented Oct 6, 2015

I'd potentially be interested in helping implement something like this. I used Tiled in a project at University last year and I had to work around this by referencing the name of an object in a custom property, so a connecting objects feature would've been really useful.

Since you mentioned using object connections in order to model physical constraints between items, I was thinking each connection would need its own property or set of properties in order to specify the type of constraint (since a physical constraint could be rigid, elastic, rotary, slider, etc). What are your thoughts about the best way to show this in the Object Property dock?

@bjorn
Copy link
Member

bjorn commented Oct 6, 2015

@naiello First of all, thanks for offering to help with this!

Thinking about your question, I considered that actually a physical constraint between two objects would really just need to be its own object, since it would need its own set of custom properties for defining the parameters. And two of these parameters would be the actual "connection" to other objects, or most commonly, the bodyA and bodyB involved in the constraint.

So I think the way to do this will be to add types to custom properties, and one of those types would be "Object reference" / "Link". That way, the custom property system can be used to add any number of named connections to other objects. Tiled now already has a simple system by which each object gets its own unique ID, so these IDs can be used as the values of these properties.

When a custom property is added of this special type, a button would be available that allows choosing an object from the scene to connect to. I think also a text input should be available in which you could search objects by name to make the link. This could look similar to the file reference properties that you find for example as the "Image" property of an "Image Layer".

Note that quite some work was previously done on this and submitted as pull request #182, but this code was never cleaned up and has meanwhile gotten very outdated. You could look at it but I'd recommend a fresh start.

@kdrnic
Copy link

kdrnic commented Aug 14, 2016

I reiterate the usefulness of this feature

@bjorn
Copy link
Member

bjorn commented Aug 15, 2016

@lucasdealmeidasm I totally agree this feature would be very useful. I've added it now to the Roadmap so that I will remember to get around to it.

@ghost
Copy link

ghost commented Nov 17, 2016

I'm doing Warping right now:
image

I would flip shit if you could get this whenever @bjorn. This would be so, so amazing. But take your time, no rush! I know in HTML 5's canvas lineTo is used and relatively speaking math isn't probably a problem for you. Not sure what to use in your system. I'd argue your time is what is at play than silly math. But yeah, this feature would be extremely beneficial. Also, it would be awesome for a future teaser trailer of tiled and showcase the new additions!

@rosshadden
Copy link

While I think there is a place for the plethora of features requested throughout this issue, I can't help but feel a simple "Object" property type would suffice. In the same way that the "File" type opens the native OS file browser, and "Color" opens a native color picker, I think all that would be needed is a button for the object value that puts the mouse in a selection mode let's users click an existing object. Which will of course insert that object's uuid as the value.

@rosshadden
Copy link

And to be clear, this would only store the property on the object it was added to. Just like every other property.

This would also work well for paths/waypoints, as each segment could have a pointer to the next, like a linked list.

@bjorn
Copy link
Member

bjorn commented Nov 24, 2016

@rosshadden Definitely, that's exactly what I meant to say with my comment from October last year. I really need to see about getting around to this feature soon.

@IcemarkUK
Copy link
Author

@rosshadden Multiple connections?

@rosshadden
Copy link

You would simply add another property, pointing to another object.

@rosshadden
Copy link

rosshadden commented Nov 24, 2016

Again though, this is a pretty basic implementation, not a robust one. I do think multiple connections could be a lot better, but I also want to see this get implemented sometime soon 😋

@IcemarkUK
Copy link
Author

@rosshadden ok.

@Martenfur
Copy link

Seeing, that there was no activity since 2016, is there any hope of seeing this feature in the future? Imo, this is one of the core features of any editor.

@rosshadden
Copy link

Yes there is quite a lot of hope. I get the feeling @bjorn wants to implement this in some capacity because of the way he has mentioned it or discussed it in many other issues. Whether it's the feature-filled request in the OP, my watered-down version that I outlined a couple years ago, or something else entirely remains to be seen. It's also listed in the roadmap so he hasn't forgotten about it, but not slated for the upcoming 1.3 release so it isn't a high priority for him yet.

I disagree with the last part you said about it being "one of the core features of any editor", but I'm sure your intentions are good and you are just enthusiastic about making an amazing tool even better 😎.

@Martenfur
Copy link

Well, I don't understand, how it can be low priority and not core functionality. Without linking I cannot do the most basic things like linking button to the gate, so it will open, when the button is pressed. Yes, there are clunky workarounds, but they are, well, clunky.

@Antix-Development
Copy link

bump I am now using objects in Tiled and it would be fantastic to be able to link objects so I know which two doors are related and also so I know which key unlocks one of those doors :)

@bjorn
Copy link
Member

bjorn commented Dec 30, 2018

This feature has been on the roadmap since a while, but so far kept being pushed forward due to other features taking priority. It was not essential for the Tiled 1.0 release, which had already grown much too large in itself anyway. Then Tiled 1.1 was mostly driven by the Google Summer of Code 2017, where this feature had been a suggested project but our students had picked other projects. Then Tiled 1.2 was mostly driven by direct requests from a few major patrons (though they requested features that benefited most people). And now for Tiled 1.3 I have picked a few important issues that I've been wanting to get around to since a long time as well.

As it stands now, this issue would definitely be included in Tiled 1.4 if I were to plan it now. That said, the roadmap is not set in stone and for Tiled 1.3 I have so far only worked towards scriptability and configurable shortcuts. If there is more demand for connecting objects than for project support, then it could be swapped.

@xylosi1
Copy link

xylosi1 commented May 12, 2019

looking forward to hopefully seeing this in 1.4, i too have the clunky workaround problem as my doors go over two tiles so linking inside tiled would be great

@justgook
Copy link

justgook commented Jul 3, 2019

suggestion 1. something such simple, easy could be done via scripting, if allow render some custom shapes (svg / canvas / glsl / existing primitives from objects - just disable selection, or let it be done over scripting too), same goes for showing / hiding stuff - easy can be done via scripts

suggestion 2.
reference to object is nice - but why not also allow to reference to other tile:
for example i have custom properties

anim.walk.east.id: 12
anim.fire.east.tileset: 5

where 12 - is index relative index in tileset, and 5 is tileset Id
so i have done that - because there is no way to find out global tile id just from interface.
Again scripting

    {
        "name": "onKey[a]",
        "type": "string",
        "value": "Move.west"
    }

they are quite simple - why not create API for scripting to allow users define they own custom types, (im not sure about XML) - but from json format - it looks quite easy to change create api for registering new type, and then just setting it as any type you wont just from script:

  1. nested objects
  2. arrays
  3. reference to other object
  4. reference to tile
  5. any anything what user only can imagine

@JoeCreates
Copy link

I would object references, and I have some suggestions.

  • First simply implement an object reference field (which uses ID, not name, because names may not be unique). The name could be displayed with it, but not editable.
  • This field could have an icon which you can drag (or just click) onto the map or object easily to select an object easily.
  • It should not be restricted to objects, but allow layers also
  • Visibility of connections could be turned of on a per reference basis.

@bjorn bjorn added this to the Tiled 1.4 milestone Aug 5, 2019
@bjorn bjorn pinned this issue Nov 12, 2019
Phlosioneer added a commit to Phlosioneer/tiled that referenced this issue Dec 22, 2019
This commit was based heavily on simlrh's PR of the same name, mapeditor#1408.

Addresses some parts of issue mapeditor#707.
@bjorn
Copy link
Member

bjorn commented Jan 29, 2020

Today I've made some progress on visualizing the connections between objects, based on the new "object" custom property type:

Screenshot from 2020-01-29 22-32-02

The patch still needs some work to make sure the lines are added/removed as appropriate, to change it to an arrow so that the direction is clear and to make this overlay optional. The shadow is also not rendering correctly when zoomed in.

I rendered the lines in yellow here, but I think it would make sense to follow the target object's color. And maybe they should be dashed to make them look less like a polyline object.

@bjorn
Copy link
Member

bjorn commented Feb 4, 2020

Visualization now committed to master. Here's how it looks:

image

Final step for now would be implementing visually making, breaking and changing connections. I'm not entirely sure how I would implement this yet, but I guess it would make sense to make a separate tool for it. And then there should be a small button next to object reference properties that triggers this tool for choosing the target object.

@IcemarkUK
Copy link
Author

Looking great!

@hexus
Copy link

hexus commented Feb 25, 2020

Yeah, that's looking awesome 🔥

@bjorn
Copy link
Member

bjorn commented May 13, 2020

I'm going to close this and await further feedback to see what would be good to improve in upcoming releases. Here's a short list of potential further improvements:

  • Introduce a tool for more easily editing existing connections. Currently, to edit an existing connection you need to select the source object, click the property value, and then click again on the arrow button to choose a new target.

    • Ideally, one might be able to click either end of a connection to move it to another object. This would be quite some work to implement, and then the problem of ambiguity needs to be solved when multiple arrows end up or originate from the same object. Potential solution: require that a connection is selected first, and only then show handles to drag either end of the connection.
  • The original feature request suggests we could add properties to a connection. This is currently not possible, but I've decided that this should be done with additional properties, eventually it can be done by defining custom structs as property type (Add support for nested (dictionary-type) properties #489).

  • Allow object references to objects in another map. This would require storing a file reference along with the object ID. In the editor, such references could only be rendered when the two maps are part of the same world. If they are not, it's also a bit unclear how to set such a reference (copy/paste?).

Any other suggestions are welcome!

@bjorn bjorn closed this as completed May 13, 2020
@bjorn bjorn unpinned this issue May 27, 2020
@bjorn bjorn added this to Roadmap Feb 3, 2023
@bjorn bjorn moved this to Completed in Roadmap Feb 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature It's a feature, not a bug.
Projects
Archived in project
Development

No branches or pull requests