Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Connecting Objects #707
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.
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.
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@example.com and include information about when you would need this feature to be done.
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?
@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.
referenced this issue
Nov 29, 2015
referenced this issue
Dec 24, 2015
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
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.