here it goes, my first forum post! Gonna be a long one…
I’m trying to implement my core feature - an Interaction System, which is based on just two buttons (on top of a simple WASD walking scheme). You control you left and right hand with your mouse buttons/triggers. Every action inside the game is based on this system. For example:
- use an item with your designated hand by clicking the button shortly
- holding a small item by holding the button and let it go, when you release the button
- holding a big item by holding both buttons/hands
- of course you can hold two small items at once, eg. a lamp and a map
- looking at your left hand small item, by pressing your right hand button, when there is currently no item in front of you to pick up
I hope you get the idea.
With this system I hope to get the player to fiddle with his environment, trying to interact as natural as possible by just using his hands in natural way.
The good: it works already(rudimentarily)
The bad: it’s extremely buggy.
I’m by no means a dedicated programmer and started the project more from a designer, 3D-Artist pov. All I knew about programming I thought myself over the last 1 1/2 years - so there’s a big possibility I made some fundamental flaws along the way. This is a student project, so it doesn’t have to be perfect, but at least playable for more than 30 seconds in a row.
Maybe you can help me out with this one
How it currently works:
The following pictures the flow of the mechanic in the left hand. Nearly the same code goes into the right hand, with corresponding variables changed. A few nodes are compressed, but the description should be self-explanatory.
The system builds up on a basic UsableObject BP, which I detect with a line trace.
After that I can either use or take it (attach to player), also depending on the settings inside the UsableObject (is even pickable, is an UsableCameraActor, which behaves differently etc.)
The animations for picking up the objects take a little bit of time, so I can’t attach it instantly to the player. Which leads to the problem, that the objects sometimes disappears. Also, I tried to prevent button spamming bugs, by using a gate. But this doesn’t work really well. Commands would grind into each other - picking up one object into two hands for example.
Here is video showing how it should work:
My question is, what would be your approach to this mechanic? How would you build it from ground up, programming wise?
Please don’t hesitate to ask, if I should clarify a few aspects of the mechanic. I want to show this system to people without collapsing after a few seconds.
Thanks in advance!