Forum rules - please read before posting.

[Integration] Puzzle Creator "Add puzzles to your game" (Asset Store)

Hi there!

I'm trying to integrate AC and PC together (PC being https://assetstore.unity.com/packages/templates/systems/puzzle-creator-add-puzzles-to-your-game-143274)

but, I'm new to both, took some time to make a crush course of both, read most of the docs and samples, did some attempts, and reading through the whole docs of both is going to be 650 pages in the best case scenario :pensive:

So I'm asking a little help :blush:

The dev of PC already made an attempt to add support for AC, but what it does is, basically:

` private RectTransform rectUIText;

public void PC_Start_A_Puzzle()
{
   GameObject tmpObj = GameObject.Find("txtHotspot");
    if (tmpObj)
    {
        rectUIText = tmpObj.GetComponent<RectTransform>();
        rectUIText.GetComponent<RectTransform>().localScale = Vector3.zero;
    }

    AC.KickStarter.TurnOffAC();
    Ap_ActivatePuzzle(Camera.main);
}


private void PC_TurnOn_AdventureCreator()
{
    AC.KickStarter.TurnOnAC();
    StartCoroutine(WaitBeforeDisplayText());
}

IEnumerator WaitBeforeDisplayText()
{
    for(var i= 0;i<10;i++)
        yield return new WaitForEndOfFrame();

    if (rectUIText)
        rectUIText.GetComponent<RectTransform>().localScale = new Vector3(1, 1, 1);

    yield return null;
}`

which is... a bit extreme and hacky. It also triggers a few randome errors on the function that handles the hotspot label position to force the label to be on screen.

The dev suggests to just fire an event on a specific object and that's it. No support for checking or custom saving.
I'd love some deeper integration and would love to know if someone has already been through it.

Here's an action I tried to write to trigger a puzzle:

https://gist.github.com/NeatWolf/4ae390fb896450dc58314da8361780c1

Yet, I'm getting a bit confused (the labels seems to be 1 based-indexed and the sockets to be 0 based).

Also, it looks like the Action gets correctly triggered on exit (both on success or fail), but actually on exit gets activated the wrong socket on completion, requiring to check it again later to get the correct completion result. Looks like the check gets done on entering and not after completing the action.

I also tried not to disable AC completely, but triggering a cutscene, also running everything in background, but the result is the same.

Has someone else tried/managed to merge the two systems in a more seamless way?

Any help is welcome, thank you :)

Comments

  • Welcome to the community, @NeatWolf.

    I should start with something of a disclaimer that AC is a complex tool, and you should take the time to learn how it works "by itself" before attempting to merge it so closely with another gameplay asset.

    Assuming you're already familiar with Unity, the fastest way to get familiar with AC's core concepts is to go through the Recreating Unity's adventure game tutorial video.

    The dev of PC already made an attempt to add support for AC

    It's a bit brute-force, granted, since he's essentially disabling all of AC while the puzzle is activated.

    See the Manual's "Integrating other gameplay" chapter for a general guide to merging other assets. A more integrated approach would be to instead use the Engine: Manage systems Action to disable select systems (e.g. "Movement") for the duration of a puzzle, so that you could still access e.g. AC's Menu system.

    the labels seems to be 1 based-indexed and the sockets to be 0 based

    I agree that that is confusing. The template should read "starting from 1" in the GetSocketLabel function at the very least.

    Looks like the check gets done on entering and not after completing the action.

    That shouldn't be the case. A Debug.Log statement in your End function, at the moment you set the value of outputSocketIndex, may clear up what's going on there.

    You should also return zero when ready to complete the Action, ie. on line 95.

    So that I can understand better, what is your exact intent here in using AC Actions to run/wait for a puzzle? Do you want to have such a puzzle play in the middle of a cutscene, surrounded by other Actions?

    One other possibility would be to complete the ActionList once the puzzle has been triggered, and either resume it or play another once the puzzle has been completed. This can be done by calling an ActionList's Interact method.

    As for saving the state of a puzzle, see this tutorial for a guide on saving custom "Remember" data. Remember classes are how AC saves scene object data - see the Manual's "Saving scene objects" chapter for more on this topic.

  • edited July 2019

    Hi Chris,

    thanks for your timely answer :)

    I watched all of your video tuts on YT and read all the relevant parts of the docs last week and lastly during the weekend :)

    I came up with a few new classes on yesterday night, I'm going to polish and publish them here asap.
    I was also wondering about the lack for DOTween support, so I began drafting some new classes for that as well :) (OT: can the "add Remember/IDs components to the whole project" be extended? I'd need to add a few extra classes and their respective Remember. EG: DOTween and Remember Transform, or PC_Puzzle and RememberPuzzle - I'd really appreciate being able to extend that!)
    I also needed a Remember component to remember the activeSelf state of a GameObject. Maybe I missed something and I'm reinventing the wheel?
    (On Unity 2019.1.8f1 the floppy disks don't appear in the hierarchy for some reason btw)

    Back on topic!
    I don't know if you know the package above, but I realised that there's some... huge contrast between the quality of your code and the one I'm trying to integrate, and I've already begun to tweak the other asset and its way to interface with AC.

    I actually discovered that there was a "softer" way instead of disabling the whole AC,

    the code above became:
    ` public void PC_Start_A_Puzzle()
    {
    AC.KickStarter.player.Halt(); // To halt the walking animation and animation event driven footsteps
    AC.KickStarter.playerInteraction.GetLastOrActiveHotspot().DeselectInstant(); //to avoid the hotspot menu from showing for an instant after leaving the puzzle closeup
    AC.KickStarter.stateHandler.SetMovementSystem(false); //not sure if needed

        Ap_ActivatePuzzle(); //needed indeed
    }
    
    
    private void PC_TurnOn_AdventureCreator()
    {
        //To avoid that the last click on the puzzle cam results in a movement action elsewhere
        AC.KickStarter.playerInput.ResetClick();
        AC.KickStarter.playerInput.ResetMouseClick();
        AC.KickStarter.playerInput.ResetDragMovement();
        AC.KickStarter.stateHandler.SetMovementSystem(true);
    }`
    

    (I don't understand the reason only half of the code in the code block gets cut away ^^")
    I didn't want to begin a cutscene, so I guess it's a better way.
    I believe I may need to save during the puzzle (custom cam), or access the inventory to check for hints. I also don't want to renounce to having all other routines of AC working in the background (you really thought about everything!)
    I did the camera switching in the AC's way by adding runtime components to it (but realised I also had to assign a static ID to work properly with savegames)

    I understand that if you don't know about the other asset it may sound a bit abstract but... do you feel I'm overdoing with disabling extra systems?

    I believe I could get to the point of replacing the entire input system of PC with that of AC, but I guess at that point I should be selling a separate asset on the store, hehe :smiley:

    I saw the forum is swarmed with puzzle threads, but I need a whole puzzle solution.
    If you, or anyone else reading, could suggest me some other more compatible/supported asset, I'm all ears :)

    (I'd also love to be able to extend the Enum of Action categories, but I fear about touching it to make it class or scriptableobjs based :P)

  • can the "add Remember/IDs components to the whole project" be extended?

    The automated Remember utility mainly works by searching for Actions that make changes that Remember scripts can save. Custom Actions can auto-add custom Remember scripts by adding an override AssignConstantID function. If the saveScriptsToo parameter is True, use the AddSaveScript function inside that to add the appropriate script. For a simple example, see the ActionRename class.

    I can consider some adding kind of interface/base class that the process also searches for to allow automation without Actions, if that would be useful to you.

    I also needed a Remember component to remember the activeSelf state of a GameObject. Maybe I missed something and I'm reinventing the wheel?

    I've stayed away from this myself as I believe it can cause problems when trying to load data from a disabled GameObject. IMO it's better to disable an individual component within, move it out of view, or have a 'disabled' state within an attached script instead.

    I don't understand the reason only half of the code in the code block gets cut away ^^

    All code needs at least one tab before it to appear in a block.

    I understand that if you don't know about the other asset it may sound a bit abstract but... do you feel I'm overdoing with disabling extra systems?

    I'm not familiar with the asset, no. But disabling AC's movement during a 'minigame' is quite standard.

    If you, or anyone else reading, could suggest me some other more compatible/supported asset, I'm all ears

    AC does naturally feature it's own logic system with variables, actionlist parameters etc, and the recent ability to attach Variables as a component makes it easier now to create isolated gameplay chunks as prefabs. It's still up to the designer to actually create the puzzles, though. AC does support Playmaker, which is also good for creating logic, but if the other asset features the kind of gameplay you're looking to integrate it's probably best to continue with that.

  • I have this system never integrated this with AC but that being a lack of coding but I have closely looked at the puzzles and I reckon anyone that really knows AC would may be able to recreate puzzles like this within AC. By using variables within AC and playmaker. I would love to see this integrated with AC as well though.

  • I have that asset also, so I support the idea! It's pretty cool approach to puzzle system and if something like that could be integrated in the AC, it would be great

  • edited July 2019

    I still have to tidy them up a bit but I have a few classes I can share which could be handy to have to make the two assets live in the same project in a bit better way :D
    I'd happily purchase a native puzzle-extension plugin made by the creator of AC :)
    I've seen tons of puzzle-related requests, and having an underlying dedicated structure/template system for them would be a boon [OT off] :P

  • That would be awesome! While it's really possible to make complex puzzles in the AC, another arsenal would be good as a choice with already predefined variants and countless possible combinations between them

  • While AC has always been more geared towards allowing users to create their own puzzle logic, rather than providing pre-made puzzles, the recent additions in v1.68 are intended to make the prefabbing of puzzle logic much easier.

    Variables can now be attached to GameObjects, the "ActionList Starter" component can be used to initialise a puzzle when the scene starts (without resorting to the an "OnStart" cutscene), and the "Set Interaction Parameters" component can bulk-set a Hotspot Interaction's parameters when clicked - allowing for a single Interaction to be used for all instances of the puzzle.

  • Thanks Chris!

    I'm sort of new so I still don't master AC very well or know each and every feature after the crash course I did with videos and examples.

    I will have a better look at those classes - I believe they can either be used to create puzzles from scratch, or to wrap all the Puzzle Creator puzzles in prefabs and prefab variants (I'm so loving them) for an easier co-existance :)

    I will keep you posted on the progresses, premising that I didn't like the way some parts of PC were thought, so I may also be changing a few of the PC source files.
    There's no need to brutally shut down AC to make PC work as per suggestion of the PC dev.
    And definitely no need to use yield to create 1,2,3 frame delays and coroutines to "avoid bugs with AC", like it's written in the PC to AC helper class :P

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.