Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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.

Product Version: UE 4.18
more ▼

asked Jan 20 '18 at 06:51 PM in Using UE4

avatar image

13 2 2 6

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

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

alt text

capture.png (200.4 kB)
more ▼

answered Jan 20 '18 at 07:04 PM

avatar image

10.1k 33 10 25

avatar image Cubengine Jan 20 '18 at 09:45 PM

Thanks Thompson, your method 1 fixed my collectible issue right away! I thought you need to "recieve the cast" on the character's blueprint and also do something with it there, but I'm not understanding how Cast works quite yet, so I gave it a shot and it works :)

About my projectiles, maybe I should start another topic for that, I don't know if i can continue with that one here. I'll reply on that here for now either way :)

If i set the projectile to BlockAll, it gets stuck in anything it hits (doesnt get destroyed). But having it on BlockAll + using an ComponentHit event instead of Overlap, it registers a hit with the coins too (I want them to pass through the coins). I'd probably need a way to tell if the Hit is on a wall, or a pass-through object. My problem is: if i make an exception to let it go through if its a coin, wouldn't I also have to keep adding exceptions for each object type that I want shots to go through? Is there any way to set these rules without manually handling each object type?

Thanks for your help so far! (I mean you solved my main post issue^^)

avatar image ThompsonN13 Jan 20 '18 at 10:10 PM

The most basic thing to know about casting imo is that its just a comparison. it takes an item and says is this item like the thing im checking for if it is then true if not then it fails . so for example lets say instead of checking if its thirdpersoncharacter your dealing with cars. if your looking to see if the item you give is a car then a ford mustang, a geo metro, and a model-A will all come true, but if you feed the cast (object in) a 747 airplane then it would fail since its not a car. its all about inheritance a mustang would be a child of car and inherit the attributes of car (basic shape, 4 wheels, engine). the reverse is not true though if you were casting for a mustang and you fed in car it should fail. All mustangs are cars but not all cars are mustangs.

This may have come out a bit convoluted and confusing but do a bit of research into child classes and inheritance. soon enough it will make perfect sense. the second method i showed in the pictures is basically how it works but is super specific in whats its looking for.

avatar image ThompsonN13 Jan 20 '18 at 10:17 PM

as for your projectile collision i would look into using custom collision in the collision presets. this way you can set if youd like to overlap, ignore, or block certain types of objects. to start id try setting block world static which would be anything not set to moveable if i remember right, then set the rest to overlap.

you can also use inheritance and casting here if its only certain items that you want to be able to pass through.

avatar image Cubengine Jan 20 '18 at 10:42 PM

The custom collision worked! Thanks! I've tried it before but my code was bleeding from so many wounds no surprise it didn't work well before haha, but now it's working perfectly for what I want it to be. Coins collectable by player only, shots hitting walls only! I definitely have some setting-up to do for my future actor types and behaviours between them.

Thanks for your quick help! :D

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question