Forum rules - please read before posting.

Lamp Puzzle (explained) below): Possible with only adventure creator?

Hello all,

I was wondering if it might be possible to create a puzzle as the following with AC's capabilities solely, or if I might need some custom scripting as well:

There is a lamp with 3 bulbs. Each time the player hits it, the lamp will display the next number in a sequence with its bulbs. The numbers range from 0-7, and the bulbs that are on represent the number's binary representation.

As an example, if the lamp is displaying the number "2", then

The left bulb is off.
The middle bulb is on.
The right bulb is off.

The player then does a "use" interaction on the lamp again, and this time, it will display as "3", so

The left bulb is off.
The middle bulb is on.
The right bulb is on.

For the puzzle, there are three lamps in total, and as such, there are three bulbs in each (so 9 bulbs in total). The first lamp is supposed to display a 5, the second is supposed to display a 3, and the last is supposed to display a 1.

I was considering creating a prefab of a lamp and somehow creating an action list that checks if the lamps are displaying as 5-3-1 each time the player makes a move on any of the lamps.

Might it be possible to do this with action lists?
If not, is it possible to run a Unity / C# script each time the player makes a move so that I could do this check?

Thank you so much!

Comments

  • You can do this with animation and parameter/variable syncing.

    First, create animations for each configuration three bulbs can make. You'd want all three bulbs to be affected by a single animation - e.g. an animation named "3" turns off the left bulb, and turns on the middle and right bulbs.

    Place each of these animations in your Animator, and use an Integer parameter + transitions to control which animation is played - e.g. a "ShowNumber" int causes "3" to play when set to 3, "5" to play when set to 5, etc.

    Next, attach a Variables component and define an Integer variable of the same name, e.g. ShowNumber.

    To have the parameter and variable be linked, also attach a Link Variable To Animator component. Fill in its Inspector - specifying the Animator, Variables component, and name shared by both.

    You can then use the Variable: Check / Set Actions as normal to access the ShowNumber variable - which in turn will affect the parameter and hence which animation to play.

  • edited April 2023

    Thank you so much!
    So I was trying to do something like [compvar:175496:0]_lamp, where [compvar:175496:0] refers to the animation "number" -- it is an integer.

    However, I'm getting an error where it says "animation cannot play".

    On the other hand, when I replace "[compvar:175496:0]_lamp" with "1_lamp", as an example, it works.

    Is there a conversion from integer to string that I may have to do first?
    Thanks!

  • edited April 2023

    Also a side note -- since there are three lamps in total (as in the lamp is duplicated three times), would a single animator work for this?

  • Nvm got it to work! Turns out that I had to link the lampHitTimes (which is the number to be displayed) to a parameter used by each lamp.

    Thanks for all your help!

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.