Download

Whats wrong with the overlap collision system?

Im making a building system, much like the ones you’d see in a tycoon game. Basically in build mode the objects are supposed to ghost through everything and if theres an overlap with another actor the game prevents you from placing that object down. Obviously im trying to use the OverlapBegin Overlap end functions but nothing is working, here is a video of what happens: Imgur: The magic of the Internet

The system works in its entirety but the collision just doesnt want to function properly. The way I move the object is simple: get mouse location in world and then lerp the object to the location, using sweep, Mesh as the root and CCD of course. The collision only works if the other actor is moving. So if the player is walking while in the block itll detect overlap but thats the only case scenario.

so annoying. Do I have to rethink the entire build system because of the way UE4 works?

You get an “actor begin overlap” when colliders (with matching channels) begin overlapping. You get “actor end overlap” when they end overlapping. If you need to know which objects are “still” overlapping, just store that information inside the “begin overlap” notification.

Other than that, it’s hard to figure out from your text what you’re actually having trouble with. Which particular blocks of code/blueprint are you trying to run, and how does it not behave the way you expect?

I actually figured it out. So for some reason actor collision doesnt check overlap during sweep functions if you dont have a collision component on it such as box collision - I was using the mesh for collision checking before hand - The engine also does not store actors that are overlapping, which was a problem for me because I have special instances of buildable objects where theres holes in the center that can accept certain items in it.

so what i did was added box collision, set its bounding box to be the size of the mesh, generated on overlap events for this component (with multitrace enabled) and then had an array on the buildable for overlapping actors. I added unique and removed actors to and from this array respectively with the overlap events and I had a function for making exceptions as well - which was basically just a function that removed an item from the overlapping actors array and did a check to see if there were any more overlapping actors in the array.

Its messy and probably has something that I didnt think about but it works like a charm for now and the exception functions makes saving everything super easy. Its just so silly that I had to go to these lengths. Even Unity has constant collision checks. It makes creating games like the sims super hard

If you are making a tycoon type game, please for the love of all that’s unholy do not just use the mesh to determine building snaps.
make a master “building” blueprint with a default square collision.
make instances of it to customize them (making the collision box bigger in predetermined steps for whatever requires it.

Having Ha"standard" makes it possible to snap buildings to roads that you build around them… unlike about 40% of modern tycoon games where nothing fits together at all (including cities skylines).

My tycoon game is a little weird because its more of just a glorified “customize this small area with props” type of thing. No snapping required. Thats what I eventually did though, on my main buildable class I have a mesh and a box that gets filled from a data asset and then the box readjusts itself to fit the mesh in construct. Its still so silly. I love this engine a lot more than Unity now but man I miss Unity’s collision system after this hellish problem