Announcement

Collapse
No announcement yet.

Input without pawns and actors?

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

    Input without pawns and actors?

    Hey everyone, I am still a noob when it comes to Unreal Engine, yet I consider myself a capable programmer in general, and therefore I really wonder why I cant figure out how this works: I basically want to resolve Input without binding anything to a Pawn or Actor. I am using a custom Player Controller, but whenever I try to bind an input action via bindAction(), it highlights the reference to the Controllers own "Resolve Input"-function as invalid.
    My goal is to simply increase an int variable which is element of my controller class by 1, whenever I press the 'W' key. Is there any way to do this without building weird workarounds including pawns? Your help is much appreciated.

    #2
    The input is received by UGameViewportClient which then dispatches it to actors and controllers. If you want to directly process the input consider deriving your class from UGVC. Note however, that this class is relatively low-level and is generally not meant for gameplay input processing.
    Last edited by Robert Khalikov; 12-05-2018, 03:46 PM.
    Realistic Atmosphere 2.0 | YouTube | Forum | Marketplace

    Comment


      #3
      Sounds good to me, I'll check it out! Thanks for the help!

      Comment


        #4
        You can bind actions directly to PlayerController functions just fine. Depending on your project setup it may be preferable.

        Comment


          #5
          Originally posted by Jocko Jonson View Post
          You can bind actions directly to PlayerController functions just fine. Depending on your project setup it may be preferable.
          For some reason I couldn't make it work. Might be me screwing up. But to be honest, the moment I saw the input functions of the ViewportClient, I kinda fell in love with it.

          Yet I did run into trouble again: Since Viewport-Client is generated "somewhere" inside the engine, is there a way to get a reference to it in my game mode constructor?

          EDIT: SOLVED! Finally found the GEngine thingy
          Last edited by BantamBree; 12-06-2018, 10:23 PM.

          Comment


            #6
            Accessing the Viewport Client from the Game Mode is generally not a good idea. Game Mode is server-only and the Viewport Client is client-only. It might be ok if you are making an SP game though. Also I would not recommend trying to find a Viewport Client (or any other engine- or game-level object) from a constructor. There is a special instance of each class called Class-Default Object created at the moment when the class is loaded. The engine is not yet initialized at this point and GEngine might not even exist.
            Realistic Atmosphere 2.0 | YouTube | Forum | Marketplace

            Comment

            Working...
            X