Collision Detection in C++
Hey everyone, So I am working on a melee attack with a sword, which will eventually be able to do things like, chop off zombie limbs or stop a animation if it hits a dense wall or chop through it if it is thin enough, etc... stuff like that, what I have to do first is detect when an object is hitting it, which I am trying to do right now:
This is the code for picking up the item and adding the collision code and later removing the item and collision code:
curItem is the melee Weapon, and it should be obvious that I am adding a delegate to when the actor begins/ends overlapping. The Item does work with physics, such as moving boxes around etc... Also I have set up the UFUNCTION() tag in the header with OnWeaponOverlapBegin/End. I cannot seem to figure out what the problem is, but no matter what, I dont see "Hit" being shown on the screen...
asked Oct 21 '15 at 12:09 AM in C++ Programming
So I figured out why it was acting so strangely. I used this instead:
The MoveIgnoreActors allows the weapon ignore the weapon that it is surrounding and the player, that way there is no chance for collision.
Thanks to matthew_clark and Timoses I used both of your answers to find the solution to this problem
It seems like the issue here is that your collision is set to Block All, but you're attempting to base your collisions off the overlap events. You'll need either set your weapon to be OverlapAll (Or some form of that) or change your collision events to OnActorReceiveHit or something of the sort. You also may wish to set up a Box Collision (Or any type of collision volume, not sure on your weapon's shape), attach it to the weapon, and run the overlap/hit events based off that.
answered Oct 22 '15 at 08:27 PM
Did you set a CollisionObjectType?
This is a good read if you're unsure if you've understood collision correctly: https://www.unrealengine.com/blog/collision-filtering
answered Oct 23 '15 at 03:08 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here