Forum rules - please read before posting.

Animate cursor on click

2»

Comments

  • edited July 2019

    A completely blank transparent texture in png format cannot exist. At least photoshop does not save anything when I do so, only if i put something like a dot it will save it.

    I did the trick with the dot to save the empty png. Now I have an invisible cursor going around the screen and a stable animating one in the middle of the screen that is not moving.

    What I want is when the player clicks on anything the pointer to play a small animation (like 10 frames) and then come to its former state.

  • A transparent PNG is perfectly possible - try this.

    In order to have the animated graphic follow the mouse cursor, you need to assign the "Rect Transform To Position" field in the script's Inspector. Unless the animation controls the RawImage's position, you can set this to the RawImage object.

    Is this animated graphic playing continuously, or only when you click (like it's supposed to)? If continuously, share screenshots on imgur.com so we can see what's wrong.

  • @ChrisIceBox ok now it works but when i use your png and set it as required by unity for cursors, (RGBA32, no mip maps, Alpha Is transparency, Read/Write Enabled and texture type as cursor or default or sprite ) I get a white box beside the working cursor ( which now animates whenever I click) Somehow the png is not read correctly as transparent. Oh and it does not show if i print screen what I see!

  • I get a white box beside the working cursor ( which now animates whenever I click) Somehow the png is not read correctly as transparent.

    Did you set the Texture type to Cursor? Let's see a screenshot of your settings.

    Oh and it does not show if i print screen what I see!

    As this graphic is now the hardware cursor, it's likely hidden automatically by your system's "print screen" operation.

  • edited July 2019

    Forget it it's solved, my bad. I had somehow forgotten the Replace mouse cursor check with a static cursor.

    Thank you so much for taking the time every single time! @ChrisIceBox

  • edited July 2019

    @ChrisIceBox Well there is still a problem. The cursor works fine, meaning when I click it plays a small 5 frame animation and goes back to being static. But when I click on any hotspot and a dialogue appears, the cursor changes to a static white rectangle and it remains like this what ever I do. Any ideas here ?

    Raw Image : https://i.imgur.com/F7p5W4n.jpg

    Canvas : https://i.imgur.com/9mI2qxJ.jpg

    Cursor manager: https://i.imgur.com/helQjJu.jpg

  • when I click on any hotspot and a dialogue appears, the cursor changes to a static white rectangle and it remains like this what ever I do

    By this, do you mean the Unity UI cursor, or the hardware one that should be hidden?

    If you're referring to the Unity UI cursor, what is the state of the Animator window at this time? Double-click the Controller field's "Move2" at runtime to open the live Animator.

    Also, what is the effect of clearing the "Unity UI Cursor" component's Raw Image To Control field, i.e. unsetting the Cursor RawImage value?

  • edited July 2019

    I think I mean the Unity UI cursor since I have Main Cursor Settings: Display cursor set to Never.

    If I double click the Move2 to see the live Animator I think the white box appears when the animator is at the one frame animation where the cursor is static.

    If I unset the Cursor RawImage I don't get an animated cursor but still when i click on a hotspot after that i get the white box.

    @ChrisIceBox you can have a better understanding here : https://youtu.be/9xNbKJlaTiA

  • Thanks for the video. I was under the impression that your cusor was animated by changing the texture. That it is instead handled by scaling the RectTransform means that the Cursor RawImage field should remain assigned.

    I cannot tell the reason for the white box, however. I think it would be best for me to see this for myself. If you can export an asset package with the files below, PM it to me and I shall take a look.

    • Your eight Manager assets
    • The UI cursor canvas, made into a prefab
    • The Animator and 2x animation files
    • All cursor graphics referenced by the Cursor Manager and Unity UI Cursor component
  • Hi Chris - having read through this and picking up on this thread, and having had a long look at the 'animated cursor' preset to try and understand what's going on... is there a resource to understand how all the systems interact? I suppose one way I is just import the preset and replace the cursor animations for 'click' and 'hotspot to idle' 'idle to hotspot' etc. But there's some stuff I'm not understanding, it looks like blend trees that I can't figure out how to access. The manual explains how a cursor's animated frames should be in a grid, but not sure how to have different animations for 'idle' and 'clicked' and 'hotspot'.

    May I ask please the best way to get started with wanting to have different drawn cursors and animations for eg:

    • an idle cursor animation
    • a cursor click on empty space / navmesh animation
    • cursor over hotspot pose
    • click on hotspot animation
    • still having the cursor turn into the inventory item when inventory item is clicked
  • The Manual's mention of arranging cursor frames in a grid is for Software or Hardware rendering. For the fine control over animation you're looking for, you'll want to use the Unity UI for rendering.

    The "Animated cursor" template is your best starting point, and modifying the Animator Controller to suit your needs. It doesn't rely on blend trees, however.

    The animations are driven by Animator parameters defined in the Unity UI Cursor component, much like Sprites Unity Complex characters.

    an idle cursor animation

    This will be your Animator's default animation state, provided no default parameter values trigger a transition away from it. In AnimatedCursor, this is the Pointer state.

    a cursor click on empty space / navmesh animation
    click on hotspot animation

    Cursor clicks are registered in the Animator with the "Click" Trigger parameter. What animation gets played is based on the currently-playing state, provided it has a Transition that reacts to the trigger. In AnimatedCursor, this is handled in a separate sub-layer that just adjusts the scale of the cursor's RectTransform, but you could remove this in favour of specific animations in the base layer.

    cursor over hotspot pose

    When over a Hotspot, the "IsOverHotspot" Bool parameter becomes True.

    still having the cursor turn into the inventory item when inventory item is clicked

    The template uses a separate RawImage, Inventory, that is assigned in the Unity UI Cursor component to be set to the selected Inventory item's graphic automatically. The pointer itself is a separate object, that gets obscured by the Inventory object when made visible via the Animator's Inventory sub-layer.

  • Thanks so much, Chris. I was able to edit the included Animated Cursor template, I think it'll suit my needs pretty well, thanks.

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.