Announcement

Collapse
No announcement yet.

Cycle through cursors in game with mouse button clicks?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Cycle through cursors in game with mouse button clicks?

    Hi all!

    I'm trying to cycle through 3-4 different cursors when I press the right mouse button over and over again.
    One click, one change. Next click -> change to the next cursor...and so on.
    Anybody knows how to do this via blueprint?

    Thanks!

    #2
    Hello!

    This is a simple way to do it.

    1 - Import your cursors
    2 - Create a player controller
    3 - Create the cursor widget

    4 - In the player controller, create the widget and set it as cursor widget. (Don't forget to show the mouse cursor in your game)

    5 - In the widget, create a widget switcher
    6 - Add some images below it
    7 - Create a custom event in the graph to switch the cursor
    8 - In the event, increment the widget switcher index (reset it if it reaches the max index)

    9 - Back in the player controller, call the event when you click on the mouse button.

    10 - Enjoy!
    Have An Awesome And Productive Day
    Alex, Youtube Tutorials

    Comment


      #3
      Hi Alex,

      Thanks, I'll try this out!
      Is it possible to use only one image that has 4 different cursors on it and tell the engine which area to display from the image? (1st click upper left, 2nd click upper right, 3rd click lower left, 4th click lower right)
      Like a flipbook or something...

      Comment


        #4
        There is multiple ways you can do this.

        Using a flipbook is more complex in my opinion, but you can import one sprite sheet with all your cursors, and then right click on it, choose 'Sprite Actions' and 'Extract Sprites'.
        You will have all the separated sprites based on your sprite sheet, then you can create a flipbook with them, or simply use them to set the image inside the widget.
        You don't need to use a widget switcher if you don't want to. You can directly switch the image source of the Image object. (With textures, sprites, materials, etc.)

        Also, you can use a dynamic material if you want.
        Add your sprite sheet inside it and then manipulate the uv coordinates with a scalar parameter.
        Have An Awesome And Productive Day
        Alex, Youtube Tutorials

        Comment


          #5
          Sounds good, thanks for the info!

          Comment


            #6
            Ok, I think I'm missing something, since it does not work.
            Where can I get and set the Cursor Widget? (image nr1)
            Also my Cursor_Widget graph looks like this. (image nr2)

            The Player controller is ok as if I uncheck the show mouse cursor, then it gets hidden. But doesn't show the custom images.

            Comment


              #7
              Now it works.

              Comment


                #8
                Ok, now I'd like to be able to check, whitch cursor image is the active one ...like is the Eye cursor active? If true, then do this, else do something else...

                Comment


                  #9
                  Well,
                  You have the index of the widget switcher (if you are using this method)
                  If the ''Eye Cursor'' is at the index 3, simply check if the current index is 3.
                  Or you can use a switch

                  Click image for larger version

Name:	aaaaaa.PNG
Views:	72
Size:	79.8 KB
ID:	1567916
                  Have An Awesome And Productive Day
                  Alex, Youtube Tutorials

                  Comment

                  Working...
                  X