Unreal Engine. Character interaction with an object and animation

Image for post
Image for post
Image for post
Image for post

What will be covered in this story:

  • Creating a Door Blueprint
  • Adding Interact interface
  • Adding an interface to the Door Blueprint
  • Implementing event
  • Adding a collision to the Door mesh
  • Creating custom character and game mode
  • Adding interaction button
  • Implementing interaction
  • Adding animation to the door
Image for post
Image for post
Image for post
Image for post

Creating a Door Blueprint

We will use a simple door from a starter content that will consist of a SM_Door and SM_DoorFrame:

Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post

Adding Interact interface

Before we will add some “interaction” we will do it in a proper way at the beginning (not simple solutions, but proper ones 😉). In simple terms: if our “object” is interactable (implements the Interactable interface) — do something. Let’s begin…

Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post

Adding an interface to the Door Blueprint

Now we will need to open BP_Door file and click on the Class Settings. In the Interfaces tab add our newly created Interface BPi_Interactable:

Image for post
Image for post
Image for post
Image for post
Image for post
Image for post

Implementing event

After clicking Implement event - Event Graph will be opened:

Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post

Adding a collision to the Door mesh

Before we will use the door from the starter content we will need to add collisions. Without it, our character will go through that door.

Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post

Creating custom character and game mode

We will need to modify our character and a game mode. We will make an extension of existing functionality, not updating an existing default implementation:

Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post

Adding interaction button

For our “interaction” we will need to specify an “interaction” button, let’s do that. Open Project Settings:

Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post

Implementing interaction

Double-click on a CustomCharacter Blueprint and add Interact action, it will be our starting point:

Image for post
Image for post
Image for post
Image for post
Image for post
Image for post

Adding animation to the door

For simplicity, I have moved our Blueprints to the /Blueprint folder. It is not required, so no worries 😉

Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post

Java, Spring, Node.js, AdonisJs, React.js and Flutter developer

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store