Announcement

Collapse
No announcement yet.

Plug-and-Play Character Interaction Component

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

    Plug-and-Play Character Interaction Component

    Hey everyone!

    I thought I'd share a little something I've put together - an ActorComponent which allows your characters to interact with each other, or with arbitrary objects in the world!
    Just add it to your actor or character - it'll have an outline when looked at and will respond to being used.

    Images (and gifs!) speak more than anything, so here's a couple:

    http://i.imgur.com/1bxJFxg.png
    What the blueprint side of things looks like on an interactive objects. There are events for OnStartFocus and OnEndFocus as well.
    The Intent enum is there to show how objects can have multiple functionalities, based on what the character wants to do with it. It contains a number of common actions such as Light, Lockpick, Conversation, Open, etc. You can then switch on these in code to do different things on a single object. The enum itself should be set before InteractWithTarget is called.

    http://i.imgur.com/2cCFgrL.png
    Inside a character blueprint where it wants to interact with stuff. Yes, that is literally it.

    http://i.imgur.com/zN85Pfz.png
    Outlines รก la Tom Looman

    http://i.imgur.com/nSOKhJe.gif
    Interactive objects support individual outlines!

    You can download the source code and the outline materials here: http://directorate.asuscomm.com/file...onComponent.7z
    The code is extensively commented, and in your blueprints you should only ever need to use the above node and events.

    Using the component is fairly self-explanatory, but the gist of it is this:

    Your player character will need one set to either Interacting Character or Interactive and Interacting Character. The latter allows your character to be activated by other characters in turn, should you wish to use this in a multiplayer environment. Do note that I haven't tested multiplayer interaction, and that there may be some replication issues.

    Any mode which includes Interacting will allow the character to see outlines of objects and interact with them. Your interactive objects will need a component as well, preferrably set to Interactive Object - this will allow them to have outlines and fire OnUsed events. If you'll ever possess them for some reason, Interactive and Interacting Character may be more useful. Keep in mind that this mode keeps the tick enabled, and while it doesn't really do anything when it's not a pawn or isn't possessed, it is an additional tick that's online.

    The rest of the properties are fairly self-explanatory. Explore! I'll be here to answer any questions, if you have them ^.=.^ Pop me a PM or post where, whatever floats your boat.

    A great big thanks to Tom Looman for his UE4 tutorials which set me on the path of creating this, as well as for his outline material. Materials are black magic.
    Attached Files
    Last edited by Jargon; 12-17-2015, 05:25 PM.
    Talk to me on qTox: E8FF4A2B55C2C3A8BC7B60F729E8884BF95CEB4FE8906AE76F5941B08E73066AF562A26C280B
    Stalk me on the IRC: jarl or jargon
    Need a launcher for your games? Check out Launchpad

    #2
    Nice work mate, and thanks for sharing it with the community!
    Game Developer @ LODZERO - My Twitter | tomlooman.com UE4 samples & tutorials | C++ Survival Game (Open-Source)

    Comment


      #3
      Much thanks, this will be quite useful

      Comment


        #4
        Short little notice! I've updated the code to comply with 4.8 standards - it's a minor thing, but it gets rid of some messages that were bugging me :P
        Talk to me on qTox: E8FF4A2B55C2C3A8BC7B60F729E8884BF95CEB4FE8906AE76F5941B08E73066AF562A26C280B
        Stalk me on the IRC: jarl or jargon
        Need a launcher for your games? Check out Launchpad

        Comment


          #5
          Handy! Does this recognize when you change what you are looking at? So on changing focus, do something with the old actor?

          Nvm, was on break and didn't have time to read through the whole thing. Answered my own question.
          Last edited by _cDub; 07-16-2015, 02:25 AM.

          Comment


            #6
            Originally posted by _cDub View Post
            Handy! Does this recognize when you change what you are looking at? So on changing focus, do something with the old actor?

            Nvm, was on break and didn't have time to read through the whole thing. Answered my own question.
            Was just about to reply x) As you saw, there's no dedicated event for it, but it would be trivial to add if you needed it.
            Talk to me on qTox: E8FF4A2B55C2C3A8BC7B60F729E8884BF95CEB4FE8906AE76F5941B08E73066AF562A26C280B
            Stalk me on the IRC: jarl or jargon
            Need a launcher for your games? Check out Launchpad

            Comment

            Working...
            X