Announcement

Collapse
No announcement yet.

How to Increase a Number From Zero From Mouse?

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

    How to Increase a Number From Zero From Mouse?

    Lets say I have a float variable called "Start" and it set to "0.0". And I want this number to increase when the mouse is moved in the positive X direction by .001. How is this possible?

    Basically:

    Start = 0.0
    Mouse moves to the right by 1 pixel
    Start = 0.001

    Any suggestions?

    #2
    Hey,

    The code in the image will do what you are looking for. If you only want it to happen when X is positive, then just have a branch, and only set the Start variable if the axis value is > 0 You may have to do some multiplication on the axis value to get exactly 0.001 to each pixel, but it will just take some trial and error, using print strings to see how the value is moving.

    Comment


      #3
      VaSSiLi,

      Thank you for this advice! I made slight progress but a new issue. I'm also targeting mobile devices and would like for this to work with the "InputTouch" event. This appears to be a new feature in 4.19. But I can't figure out how to translate to moving an object. "InputTouch" has a "Location" vector node. I could split this to get the X,Y,Z, but not sure where to go from there. Any suggestions?

      Comment


        #4
        Unfortunately, I know very little about mobile, and I'm not really sure why you get a 3D position vector when touching a 2 dimensional surface. Maybe someone else here has some more experience with mobile and/or touch interfaces. Is your game a 3D game or a 2D game?

        Comment


          #5
          Originally posted by VaSSiLi View Post
          Unfortunately, I know very little about mobile, and I'm not really sure why you get a 3D position vector when touching a 2 dimensional surface. Maybe someone else here has some more experience with mobile and/or touch interfaces. Is your game a 3D game or a 2D game?
          It's for AR on a mobile device. Basically pinching your fingers on the screen should expand the size of a 3D Object in AR space. I've been looking into the "Get Player Controller" > "Get Input Touch State" > "Make Vector 2D" function but this doesn't seem necessary when the "InputTouch" already has X,Y,Z, out-nodes. I don't know. Im at a loss on how to get this to work.

          Comment


            #6
            Since I have no experience with mobile, how are you testing this? Does Unreal have a kind of virtual phone you can run to test your "touches"? My assumption from reading a little into the documentation is that your Vector that comes out of the input touch event, will end up being 0 in the Z axis, and the other two numbers will be your X and Y screen coordinates.. If you break the vector, and just use the X location to drive the size of the 3D object, maybe that would work? Try the blueprint I just linked. You will have to have some way to set your "Target Actor" variable. This wont be perfect, but it might help get you started.

            Comment


              #7
              According to https://docs.unrealengine.com/latest...put/index.html you can set up a virtual joystick. But still, i think that the location output pin tells you only the location of the first touch, so this setup should scale the actor randomly.

              Comment

              Working...
              X