Check Overlap for moved Actor
I have to move an Actor (StaticMesh) from C++ using SetActorLocation.
How can I check an overlap with all other Actors on the scene to avoid unnecessary overlap.
Something like this,
The main thing is to find an overlap with all other actors.
asked Dec 08 '17 at 09:33 AM in C++ Programming
There is a function called TeleportTo. Useful for just instantaneously moving to positions. Sweep means that the object will collide with things as it moves to the target location. If you want it to just teleport, make sure sweep is false
This is some random example code I found in one of my projects. So here, when the character hits something, it will check if its an inventory and if it is, will pick it up. For character collision, you could just do an OnComponentBeginOverlap on the character's capsule component. That will work fine but NotifyHit should work also. Try putting this SetActorEnableCollision(true) in character constructor or change collision presets to block. SimulatePhysics also. Just mess around with the collision settings and it will work, I don't remember all the exact settings you have to change.
answered Dec 09 '17 at 07:18 PM
If you want to check for blocking hits, use this and put whatever you want to do inside. Make sure your mesh actually has a collision defined and that collision presets are set to block and GetStaticMeshComponent()->SetNotifyRigidBodyCollision(true) is in your constructor or BeginPlay:
for overlaps, define this function and make sure bGenerateOverlapEvents is set to true in constructor or BeginPlay:
Also, you have to bind that overlap delegate (the OnOverlapsBegin function I wrote above). So you would have to do this in BeginPlay or PostInitializeComponents:
Finally, you can also use this function for overlaps which is much simpler if you're not comfortable with using delegates:
Follow this question
Once you sign in you will be able to subscribe for any updates here