Over the last week I made a bunch of a new art and did polish pass on the gameplay system. In the prior gameplay systems posts I was working with a single variable that controlled install and removal called “bInstalled.” This was good for testing the flow of communication and getting the basic structure working, but in practice it only prevents the player from installing two parts into the same spot. I now use 3 boolean variables: bAllowInstall, bAllowRemoval, and bInstalled. These do exactly what they sound like. In each child object blueprint I collect bInstalled properties from all the necessary dependent parts and use them to set the status of bAllowInstall and bAllowRemoval. I only need to check dependencies one step removed so the lists are generally pretty short. This is an example of a child class blueprint:
I also made some significant changes to how players pick up objects. In the Unreal VR template object pickups occur when a valid object overlaps a sphere that is hovering near the player’s hand. This is too cumbersome for grabbing small parts off of an assembly and it has a tendency to grab captive parts that shouldn’t be reachable. First I replaced the sphere with a narrow capsule to allow for tighter pickup targetting. This improved the “fat-fingering” issue but didn’t help with the captive part removal problem. A good example of this would be pulling the axle nut off of a hub without first removing the dust cap. To solve this I replaced the sphere overlap check with a ray cast from the hand. I also added a visual indicator to show the grabbing range and tell you if the part is allowed to be picked up or not. When the players hand is near a pickup object, I render a shaft of light coming from the players hand. When you pull the trigger to attempt a pickup, a ray is cast out of the hand and stops when it hits an object. If the object’s bAllowRemoval is set to true, the shaft of light turns green and you can pick up the part. If the bAllowRemoval is false the shaft turns red and the part stays where it is.
Here is a video: