Inventory System UE5 Pt2
We are going to be picking up where we left off in part one in our player character.
We are going to create an event tick (every frame this is called). We then are going to do a line trace which searches and sees if a collision takes place. We then get the camera from our player and our players location (this is our starting point) and the forward vector (1) of our player and multiply it times the distance we are going to look. We are going to set it too 300.
After our trace we are going to branch out if we hit an object in our sight we are going to look at the actor and we have to get the message appearing saying we are looking at an object.
We then are going to collapse our function to Interact Trace.
We then are going to create an new blueprint that is an Interface is called InteractionInterface. We are going to create 2 new functions.
We now have to go into the project settings and search for the New Trace Channel and add a new channel. This will be an Interactable channel set to Ignore.
Next we are going to create an Actor Blueprint called ItemTest and add a cube component. Collision settings OverlapAll. Then select custom. Change Interactable box to be a BLOCK tick box.
Go to class settings of our character blueprint. Right hand side Interfaces>Add>Interaction Interface.
On the left hand side we now see our functions that we had made.
Back in character blueprint Trace Channel>Interactable
We now recognize our object when we walk up to it.