Forum rules - please read before posting.

Filling out a Paragraph with collected words - Puzzle Logic

Hi, I bought AC a few days ago, It has been really helpful and intuitive to use, best purchase of my life. I've kept reading the manual and trying to figure out stuff on the Puzzle Template: Simple Examples, but I have hit a roadblock and I can't wrap my head around it.

What I'm trying to do is gather words from a scene which then get added to my AC inventory menu, already done this part through hotspots, and made an icon for each word added (display type : Icon only) for color coding different word types. and I have Drag and drop inventory interface? checked, so that I can drag and drop these collected words with a single click. Will probably link a prefab to them later with the correct size.

What I'm stuck at is, to solve a level you have to use your collected words to fill out a paragraph that has missing words by dragging the collected words from your inventory menu and dropping it into the missing word hotspot. The game will not give you any confirmation on whether you are right or wrong until you place a word on every missing word. Then it will tell you if you are wrong, have 2 mistakes or less, or you're correct.

Would appreciate it if anyone has done anything similar and can point me in the right direction for approaching this.

Comments

  • Welcome to the community, @Conspiracy.

    As this is a visual issue, could you share some images/mockups? It will help clarify the specifics of the situation.

    If you're using the Inventory, you'd need to define Inventory interactions on your Hotspots that will cause the relevant word to appear when used.

    One way to do this would be to have each possible word as a separate sprite in the scene, parented to the Hotspot, and then have the correct one shown (and others hidden) as part of the Hotspot's inventory interaction. You can also attach a Variables component to the Hotspot, and define a Bool variable to represent whether or not the correct word has been placed there.

    It'd be a bit elaborate if you have many words/Hotspots, but you could alleviate things through scripting once you have the correct logic working for one.

    Though, the behaviour you're describing sounds similar to the "Item arranging" template also available on the Downloads page. This uses its own system to automatically place drag-and-dropped items into specific parts of the scene, with an automatic "win" state once all pieces are in the correct place. I'd recommend importing it and giving it a try - is that more along the lines you're going for?

  • Hi,

    I've been looking at the "Item arranging" template and I've noticed that it does what it does by mainly 2 scripts, one on the parent (manager) where you can assign your slot and balls, and another script on each ball that defines the initial slot and the correct slot.

    My concern is that the equivalent of the balls in my project are the words collected (inventory items), and as far as I'm aware, you can't attach C# scripts to items in the inventory (Items tab in AC Game Editor). I could be mistaken, but I haven't found a way to do it.

    So, I decided to implement the first solution you suggested, even though I'll eventually be using around 30-40 words and ~10 slots for each level. I want to get the functionality right first before I start thinking about scaling things up. In my prototype scene, I have 3 words (inventory items) and 2 slots (hotspots), and I have each sprite in the scene parented to its respective hotspot. As shown here : https://imgur.com/a/GoSp0Mp

    My question is, how do I define the inventory interactions on my hotspot so that the correct sprite becomes visible when the item from the inventory is dropped on it?

  • My concern is that the equivalent of the balls in my project are the words collected (inventory items), and as far as I'm aware, you can't attach C# scripts to items in the inventory (Items tab in AC Game Editor). I could be mistaken, but I haven't found a way to do it.

    At this stage, I was just looking to gauge how similar the template is to your intended mechanics. The scripts can be modified / added to if the behaviour is close enough.

    For example, you could attach a new script to each "Piece" object that ties it to a given Inventory item - causing it to become hidden if that item isn't in the Player's inventory.

    how do I define the inventory interactions on my hotspot so that the correct sprite becomes visible when the item from the inventory is dropped on it?

    A Hotspot's Inventory interactions can be defined at the bottom of its Inspector - see this tutorial for details.

    Bear in mind, though, that Hotspots need a little more work to have them work with UI objects. If you're attaching the Hotspot component to your UI, you'll need to also attach a 2D Collider, place the object on the Default layer, and switch the Canvas' Render Mode to Screen Space - Camera.

    So far as each Inventory interaction goes, the "brute-force" approach would be to have a pair of Object: Visibility Actions - one to hide all the child sprites, and another to then show the correct one.

    As you're looking to scale up, however, it may be more practical to rely on a bit of custom scripting to handle this automatically, by extracting the currently-selected item when a given Hotspot is clicked, and displaying that item's texture as a child object. I can advise further on this, but it'd be best to see which of the two approaches above you want to take first, and get the functionality working for your given example.

  • edited March 9

    I'd like to take the 2nd approach so I went and got rid of the UI objects to make it easier to work with. I now have 3 sprites parented to the hotspot, with the hotspot having the following ActionList on the inventory interaction with one of the items. it should make 2 of the sprites invisible and the correct one visible. but nothing happens when I drag and drop the item (painting word) inside the hotspot. Here are some of my settings : https://imgur.com/a/gUsrcRQ

  • So long as your Hotspot's 2D Box Collider spans the visible sprite, looks like it should work. Does the Interaction ActionList alter the sprites as intended if you click "Run now" in its Inspector at runtime?

    If so, we'll need to see if this is an issue with the Hotspot or some other aspect. Try temporarily making a "Use" interaction (just with e.g. a Dialogue: Play speech to show some debug text), then check Single 'Use' interaction? in the Hotspot's Inspector - does clicking the Hotspot without any item selected then cause it that Interaction to run?

    If not, are there any Menus that - even if invisible - overlap the portion of the same screen? Try temporarily swapping out your Menu Manager asset file to Default_MenuManger. Select the Inventory menu and set its Alignment to Lower Left. Is the Hotspot name then showing up when the mouse hovers over it, and are Inventory interactions then available?

    We can reduce the number of Actions involved in this interaction, but let's get the Hotspot working first and we'll take things from there.

  • edited March 10

    It works now! After I removed the UI objects, I had the text on a menu, and it did overlap with the same portion of the screen as the hotspot, which was causing the issue. Since I won't be interacting with the text, I can keep it as a UI object or just have it written in the background image.

  • Thanks for the details.

    You can keep UI objects overlapping if that's easier - removing the Graphics Raycaster should prevent it from interfering with interactivity.

    For the ActionList: there are a few steps you can take to reduce the number of Actions / lists needed, which'll help once you start to expand the logic with more words and sentences.

    First, add a new empty child object to Painting_Slot, and parent the current word child sprites to this instead. You can then use a single Object: Visibility Action to turn them all off - just reference this new empty and check Affect children?. This way, you can combine the first two Actions in your current list to one.

    Next, you can reduce the number of Interaction ActionLists by using ActionList parameters, which allow you to recycle by altering their field values at runtime.

    To do this, rename your "Painting_Slot: Painting2" ActionList to a more generic "Painting_Slot: UseInventory", and in it define a GameObject parameter named "Word to show". Have this parameter override the "Visible" Action's Object to affect field.

    For each of the three words the Painting_Slot Hotspot can be used with, you can now use this same "Painting_Slot: UseInventory" ActionList. Create the three Inventory interactions and assign the same list. Then, to have them each set the correct value of Word to show, attach three Set Interaction Parameters components to the Hotspot, and map them to each of the three interactions - and assign the correct "Word to show" child sprite values.

    You should then have the Hotspot working with a single Interaction that contains only 2 Actions. More words can then be added to the Hotspot by attaching a new child sprite, and defining a new Inventory Interaction for it.

    At least, that's the intent. I appreciate there's a fair bit to unpack here - but if you run into issues just share details/screenshots and I'll try to spot what's what.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.