I'd like to shortly animate my cursor whenever I click. Such that it plays maybe 1-3 frames and then goes back to the default non-animated sprite of the current cursor.
My interface is set to 'Choose hotspot then interaction'. I will mostly be working with 'Single 'use' interaction' hotspots, but my hotspots will be set to different cursors (i.e. I will for example have a 'use' cursor, a 'pick up' cursor, a 'talk to' cursor, etc.).
I'd like to animate my cursor on click both for my 'walk' cursor (i.e. when not clicking on hotspots) and for my other cursors (i.e. when clicking on hotspots).
I guess I will have to write a custom script for this, but perhaps someone could give me some clues about how I should approach it?
Comments
http://pasteall.org/1321291/csharp
However, I still think relying on an entirely UnityUI-based cursor may be the answer. You can use events similarly to tweak things if necessary, but here's a sample script to demonstrate:
http://pasteall.org/1321292/csharp
MY GOD such a simple thing need all this to make it work? Who would have thought. I really have to study this to make something so simple
@Antonis: A script for a Unity UI-based cursor has since been posted on the wiki. It can be adapted further to suit your own needs, but allows for animation control through the use of Animator parameters.
@ChrisIceBox yeah but it doesn't really explain anything. It is given with the minimum info
The issue is complicated because the way you might want the cursor to behave can be so varied. The script offers full animation control over the cursor, but the cursor itself is very complex - with different states, icons, and inventory items.
The wiki page does assume prior knowledge of Unity UI / Animation workflows, and how the script is used is down to you, as each user's needs will be different. Please state exactly what behaviour you're looking to achieve - how, and when, you want the cursor to be animated.
To use the script for just animating the cursor when clicking:
Further tweaks to the script can be made if necessary, but that should get you a simple cursor click animation. Try following these steps, and if you get stuck please share as much detail and screenshots as you can so that further help can be given.
I m trying to re create what you said here.
One point to ask is, do I set the Click trigger also when there is a transition from the moving animation of the cursor to the other animation that has only one frame?
In AC do I remove the cursor icon that is there (not animating) in Main cursor settings ?
When you say empty cursor texture to the empty texture field you mean a completely blank transparent texture ?
Up to the moment I have a cursor in the middle of the screen that animates when i click but there is another cursor ( i suspect taken from the main cursor settings) that is static that is it is not animating but follows the mouse movement.
PS: thank you for all the help. I would never have thought it would be so complex to just have an animated cursor upon click.
It is strange. This is what I am getting. https://www.dropbox.com/s/w42kly9metejf1w/error1.jpg?dl=0
One cursor within the red frame which animates upon clicking but does not move. And another cursor which is now shown in print screen that is bigger and is not animating but can move around.
No - only from the single-frame to the click animation. The click animation should revert back to the single-frame once it has come to its natural end.
So long as you supply the "Empty Texture" field, that should override the main cursor.
A blank transparent texture.
It is a complex thing to do in Unity, but again - if you can share exactly what you want, I may be able to offer a more simple solution. By this I mean that I need to know precisely how you want your cursor to behave at all times, i.e. do you want it to change when hovering over a Hotspot, or when an item is selected - and is it animated then as well? All these details contribute to the complexity, which is why there is no "one size fits all" approach.