I have worked on Unreal engine games for years but haven’t done any scripting, kismet, or blueprint. My only programming knowledge comes from making text adventure games in Q basic almost 20 years ago. Fortunately, I am comfortable with node based shaders and, having worked in games for a long time, I understanding some of the basics like variable types and how to lay out simple systems. I am currently working on the first iteration of a system to snap and unsnap parts from the car.
Again, not being a programmer there may be a better way to do this. I am open to feedback and expect to be iterating on these systems. That said, my plan looks like this:
There are two types of objects. A master object that holds parts, and the car part parent class objects that the users interact with. The Master Object (MO) is a blueprint with a skeletal mesh that has sockets placed where each car part needs attach. The MO doesn’t have any actual geometry (I think I need to skin a single triangle to it in order to bring it into Unreal) but populates itself with car part objects. I would also like to implement IK to allow the suspension to move correctly as the car is raised and lowered on the lift. The MO will be responsible for keeping track of which parts are on the car and what their condition is and will need to be something that can be saved and loaded. The car part Parent Class (I’ll call this PC) will have have a bunch of variables to define things like what static mesh is used and what the condition of the part is. Each part also needs to check a list for assembly and disassembly to see if dependent parts are installed. Basically, it needs to know if the part is free to be removed, or installed, and if what you are attempting to bolt it to is actually there.
I am working from Tom Looman’s VR template and using his pick up interface. So far I have implemented a simple system for parts to snap and unsnap (with no checks to prevent removal or installation). Most of the work is in the car part blueprint, the MO is just some sockets on a simple skeletal mesh and a collision box to detect when a part is nearby.
My car part blueprint looks like this:
Basically, when a part enters the collision volume I set a bool, “Is Overlapping,” I use that collision event to get a reference, and I cast to the master object to pull information from it. The blueprint checks the location of the socket and compares that vector to the world location of the part. If the difference between the two vectors is less than the variable Snap Distance, it attach the part to the master object at the socket. There is also a loop to get the blueprint to continuously perform that check while inside the collision volume and for debugging I am constant printing the distance between the socket and the car part (while the bool is overlapping is valid).
Here is a video of the system in action (framerate while capturing video is terrible).
I’ve been watching this progress for a while now and it’s looking great! Can’t wait to get my hands on it and try it out. I had one question with the blueprint you’ve posted above. I tried to replicate what you’ve done step-by-step, but I can’t get the snap function to fully work. I have the distance to snap display properly, but no snap. Any advice for how to get this to work? Thanks!