Forum rules - please read before posting.

Animate over hotspot

edited July 2015 in Technical Q&A
Hi Chris,

Just a quick one and was wondering if possible...

Like the title says, was looking to play an animation on a sprite when over a hotspot. Not sure if this feature is implemented, or if i just cant think of a way (or find it).

If not, no big worries, would have been nice to animate the back arrow when mouse is over the hotspot is all.

Cheers

Gavin

EDIT: btw is there like a HD resolution image of the adventure creator logo somewhere that I can use as a splash screen on game boot up? (png file preferably)

Feels only right ;)

Comments

  • Where is the sprite?  If you mean you want to animate the mouse itself, you can define a "Hotspot" cursor texture in the Cursor Manager.  If the texture is a sprite-sheet, you can animate it.  Otherwise, you'd have to use a custom script to detect if the mouse is over a hotspot:

    if (AC.KickStarter.playerInteraction.GetActiveHotspot () != null)
    {
      // Play some animation
    }

    Thanks - an HD logo can be downloaded here.
  • Sorry i should have clarified.

    Not animation of mouse.

    The sprite is a gameobject with a sprite rendered on it. Which also has a animator controller on it.

    So do i assume that i just put this code on the hotspot, and call the gameobject animation?

    Thanks

    Gavin
  • You can put it anywhere - that code will check for whether or not any Hotspot is being hovered over, not a specific Hotspot.  Better to put it on the sprite itself, then you can reference it's animation / animator component directly.
  • Sorry to reply to an old thread however I believe this has helped me out! I was previously using the Run Action List When Turn On for the hotspot menu to trigger an animation trigger within the hotspot's animator so that it would play the necessary animation that I wanted. It worked fine however the problem I was having was that if I moved away from a hotspot whilst it was in the middle of playing the necessary animation then when I activate a different hotspot the animation would continue playing from it's last position (so halfway through) as opposed to starting a fresh. I tried many different things such as Bool's instead of triggers and rearranging animation layouts and transitions however I do believe that the above solution is exactly what I need.

    Apologies again for opening up an old thread however it helped me out and wanted to pass on my thanks (and bringing the thread forward might assist someone else having a similar issue)?
  • Situations like this are now recommended to rely on custom events, which can be used to inject code when AC performs common tasks.  In this case, the OnHotspotSelect event - which is run whenever the mouse hovers over a new Hotspot.

    A tutorial on custom events can be found here, but the general principle is:

    private void OnEnable ()
    {
        EventManager.OnHotspotSelect += MySelect;
    }

    private void MySelect (Hotspot hotspot)
    {
        Debug.Log ("Select: " + hotspot);
    }


    Since the Hotspot being selected is a parameter, you can use that to determine if the correct Hotspot is being selected.  A similar event exists for deselecting - OnHotspotDeselect.
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.