We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.

Dynamically-created object name in the “when clicked” puzzle

Home Forums Puzzles Dynamically-created object name in the “when clicked” puzzle

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #74886
    Brameister
    Participant

    Hello everyone,

    I’ve come across an issue that I can’t seem to solve. I have objects (in this case, they are bars) that are copied/cloned multiple times and connected among each other.

    The issue is that I need a puzzle to make sure that when I click any of the bars, the clicked bar is set as the “active bar”, for several purposes. However, the cloned items have dynamic names, and the following puzzle I created for the “when clicked” puzzle doesn’t work:

    The issue is the create text puzzle used instead of the standard object name string.

    At first, I thought the issue was the fact that the ActiveLayer variable is a number, but in S8S’s documentation for the “create text” puzzle, they say that “If you provide non-textual values such as numbers, they will be automatically converted to text”. Plus, I’ve been using this structure to set dynamic object names everywhere else in this project and had no issues.

    If the issue is the concatenation of string+number, is there any way I can convert the variable’s number value into a string? Or is the real issue something else completely unrelated?

    #74891
    xeon
    Customer

    You may find this helpful.

    https://www.soft8soft.com/docs/manual/en/puzzles/Events.html#picked_object

    Best when used with when click and all objects. You can create a if statement to insure the object name suffix is correct then take action

    Xeon
    Route 66 Digital
    Interactive Solutions - https://www.r66d.com
    Tutorials - https://www.xeons3dlab.com

    #74892
    Brameister
    Participant

    It really amazes me how easy this is for you guys :-) I’m a huge fan of you and kdv!

    Thanks so much for the help, Xeon. Worked like a charm, so simple and sophisticated solution.

    #74894
    xeon
    Customer

    No problem… glad I can help. This forum has helped me so much it’s the least I can do. I am still learning too.

    Xeon
    Route 66 Digital
    Interactive Solutions - https://www.r66d.com
    Tutorials - https://www.xeons3dlab.com

    #74910
    Brameister
    Participant

    For future reference and other people that may struggle with this like I did, here’s what I came up with after Xeon’s awesome insight:

    #74911
    kdv
    Participant

    If your scene have several other objects except the cloned bars then it won’t work correctly if you click on one of those objects. Add some logic to filter the bars by their names…

    Puzzles and JS coding. Fast and expensive.

    If you don’t see the meaning in something it primarily means that you just don’t see it but not the absence of the meaning at all.

    #74912
    Brameister
    Participant

    If your scene have several other objects except the cloned bars then it won’t work correctly if you click on one of those objects.

    Thanks for the input, kdv! There is only one original bar object, from which all of the clones are made. It’s the “starting bar” so to say and I also need it to be the active bar when it is clicked. So, I think it will work, right? But the notion of adding logic will certainly be extremely useful in the future.

    Thanks again to both of you V3D gurus!

    #74916
    xeon
    Customer

    Since you are using the “all objects” puzzle…you will want to validate the user has not clicked on something else other than the required objects. In my example below I am assuming;
    the original objects name has the word “bar” in its name and that no other objects in your scene have the word “bar” in their name. If so this will work.

    Because their could be other objects in your scene that are not clones…any object you click on will return the name of the clicked object. This may or may not be what you want. So this logic ensures only the objects with names with the word “bar” in them will execute your command to print to console.

    Attachments:
    You must be logged in to view attached files.

    Xeon
    Route 66 Digital
    Interactive Solutions - https://www.r66d.com
    Tutorials - https://www.xeons3dlab.com

    #74945
    visualizer
    Customer

    Hey Polypix
    interesting learning
    Can you share the end result achieved by using this setup?

Viewing 9 posts - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.