My collectibes are activated by any overlaps
Hey everyone! I have a problem that I ran into while making a test map. The basics: I have the starter player character from template, can run around, and a 3rd person camera that follows him. I have a few collectible items (a mesh with a box collision), instances of the same blueprint class. They detect if their collision box "begins overlap" and destroy the actor. If i run into the collectibles, they disappear as intended.
After this I wanted to give the player a weapon. I made a simple blueprint, it shoots projectiles that fly from the gun's barrel forward. This is where the problem occurred. The projectiles also activate the collectibles' overlap events, thus shooting through said collectibles destroys them. I want the collectibles to only be affected by player overlap.
What I've tried: Playing with the collision types of both the projectile's collision element (a sphere collision), and the collectible's (let's call them coins for simplicity) collision elements. The coins are either not reacting to anything, or they are activated by both. I think the problem lies in the coins not checking with what they are colliding. Any overlap destroys them.
I'd like to somehow tell the coin to check if it's the player capsule component that's touching it. I'm new to UE4 and I'm suspecting the solution is in casting some info between the two blueprints, but I don't know how to do it properly. Can anyone please help with this? Thank you a lot in advance! :)
A little extra if anyone would be kind enough to also help with: My weapon's projectiles go trough any walls (static meshes), something with handling collision events there as well. Projectile's collision is set to "OverlapAllDynamic". Tried all options, no change at all.
asked Jan 20 '18 at 06:51 PM in Using UE4
what you want to do is, just after the begin overlap on the collectable cast to the players class. so if your using the third per son character you would cast to that class and connect the the overlapped actor pin to the cast node. if the cast is true then do your destroy actor scripting. if the cast fails then do nothing. alternatively you can do the same thing with a branch by get player character then use a equal(==) node to check the player character against the overlapped actor then have the result plugged into the branch.
Depending on the class that you cast to you can make more or less defined objects able to activate your pickup. for example you could change the cast to thirdpersoncharacter to just cast to character and any character could activate the pickup
For your projectile collision there are two methods you can try here also. you can either set your collision to block all which would make the projectile unable to pass through anything. Or you could have a event on begin overlap that destroys the projectile when it begins overlapping any object. there are more in depth solutions that mix situations but thats the basics
Follow this question
Once you sign in you will be able to subscribe for any updates here