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"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

Sphere Collision overlap event not working

So since I can't change Peripheral Vision Angle in BPs I decided to try adding a Sphere Collision to my Flashlight BP in the shape of the spotlight cone radius and added an Overlap Event when it hits my Enemy BP, so that the enemy chases the player.

For some reason it's not working. I believe it's something stupid, but naturally I can't see it.

Product Version: UE 4.18
more ▼

asked Dec 23 '17 at 09:42 PM in Blueprint Scripting

avatar image

14 2 3 6

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

2 answers: sort voted first

Hi Pachyderm,

Your Overlap event is failing at the Cast to BP_Enemy node. Not only your Object references are invalid, your nodes are not fully connected. In order for it to work, the white curve which indicates the execution flow must first go through Cast To BP_FlashLight node. Then you should connect its output execution pin to Cast To BP_Enemy and so forth. At this point, you should see the Hello message printed on your screen but your AI Move To node will fail as both Pawn and Target actor are invalid and will never fire. You need to first tell those two nodes what their Input Objects are, as well as making sure that they are executed by passing the execution flow through them. Alternatively, you can first do all your casting when the Overlap event fires, save the output of each of those Casts in a separate variable, and then use those variables. If you don't want to do that and you're sure that your Casts will never fail, you can right click on them and convert them to Pure cast (However, I don't recommend doing this for now unless you know what you're doing.)



more ▼

answered Dec 24 '17 at 03:55 AM

avatar image

1.5k 10 10 17

avatar image Pachyderm Dec 24 '17 at 04:53 AM

I scrapped what I had and started over trying my best to follow your directions. I feel like I'm just overlooking really stupid things because when it comes to me and programming that's always the case when something isn't working.

avatar image Vizgin Dec 24 '17 at 05:14 AM

I'm not sure what logic you're trying to implement for this overlap event here, but I assume what you wanna do is to check if the FirstPersonCharacter has entered the Sphere collision area and then have your AI BP_Enemy run towards him. If that is what you're trying to do, here's how you do it:

Take the execution pin from ActorBeginOverlap and connect it to Cast To FirstPersonCharacter. Get the Other Actor pin and connect it to Object pin of First Person Character. Whenever someone/something enters this overlap zone, the Event node fires and flows into the Cast node. The Cast node here checks whether the actor who entered the overlap zone is indeed a FirstPersonCharacter. If it is, then it will fire the top execution pin, else it will fire the Cast Failed and you know that it was someone/something other than the FirstPersonCharacter that entered the overlap zone. I suggest you connect each of those Execution pins to a separate Print String to see what is going on here.

Next get your Enemy from somewhere, and pass it to Pawn pin (You probably do NOT need to Cast it to BP_Enemy if you created it based on Pawn blueprint.). Connect the output pin of your FirstPersonCharacter, i.e. As First Person Character into the Target Actor, and the execution pin as well and things should work fine.

Unreal Engine has a steep learning curve and I suggest you start with basics and learn the fundamental of Blueprints first before trying to build any game or implement any logic. Epic has provided a comprehensive and easy to follow documentation on Blueprints that you can start and read from here

avatar image Pachyderm Dec 24 '17 at 05:20 AM

I should have said this before but here's what I'm trying to do: - I've got my FirstPersonBP which is holding a flashlight mesh - I then made a BP_FlashlightLight which I added into the FirstPersonBP and mounted it to the flashlight - I added a sphere collision to the BP_FlashlightLight where the spotlight radius shines out to

What I want is for that sphere collision to draw enemies to the player when it overlaps them; in other words, if the player is shining their flashlight on the enemy, the enemy should move to the player.

avatar image Vizgin Dec 24 '17 at 05:30 AM

Then your Other Actor pin that comes out of overlap event is the enemy and you must cast it to BP_Enemy instead of FirstPersonCharacter. If the cast succeeds, connect the As BP Enemy to Pawn, and the execution pin to AIMoveTo. Now you need to get your actor from somewhere. In your case, you can even tell your AI to run toward either the Flashlight or FirstPersonCharacter. Right click and type self reference, and get a reference to self and connect it to TargetActor. If your inside the Flashlight blueprint you'll get a reference to your flashlight and your AI will run towards the flashlight. If your in your FirstPersonCharacter Blueprint, your AI will run towards your character.

avatar image Pachyderm Dec 24 '17 at 05:37 AM

Thank you very much, Vizgin. I appreciate your patience with me. I'll be sure to come back and update this when I have a chance to implement your suggestions.

avatar image Vizgin Dec 24 '17 at 05:41 AM

You're welcome. Please don't forget to mark the question as SOLVED if your issue has been resolved.

avatar image Pachyderm Dec 24 '17 at 05:54 AM

I feel like I'm closer, but perhaps I'm confusing my execution sequence a bit?

avatar image Vizgin Dec 24 '17 at 06:07 AM

Remove the Flashlight Cast and Light Sphere completely. Connect the overlap execution pin to Cast To BP_Enemy instead.

avatar image Pachyderm Dec 24 '17 at 06:14 AM

It still doesn't seem to be working. My enemies will just stand there. Is it trying to overlap the root scene which is mounted to the flashlight instead of the collision sphere or spotlight cone? That's why I was trying to cast it to the LightSphere (collision sphere).

I've tried applying the logic to the OverlapComponent event from the LightSphere but that also isn't working.

avatar image Vizgin Dec 24 '17 at 06:25 AM

Unfortunately, it is very hard to assist you with this without having access to the full project or seeing your full actor setup. These are also basic stuff so again, I highly suggest you to start with the fundamentals of Blueprints first.

As for my last comment on your question which will hopefully resolve your issue, if you are inside your FirstPersonCharacter and you have added a collision sphere component to it, then select the collision component, on the right side, in the details panel, scroll down and select something like OnComponentOverlap event. It will take you to the Event Graph and you should now see a new Overlap event node added there. Use that node and its execution pin instead of the current EventActorBeginOverlap node.

Good luck and Hope you get it working. And please don't forget to mark the question as resolved if you managed to fix it.

avatar image Pachyderm Dec 24 '17 at 06:34 AM

I managed to stumble upon just that, though it still wasn't cooperating. Turns out my Collision sphere needed to be about 100x bigger in order to hit my enemy, which looking at the viewport I would not have guessed would be the case.

Thanks again for your help and patience!

avatar image Vizgin Dec 24 '17 at 06:41 AM

You're welcome. I'm glad you resolved it and I could help as well.

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

i think the white pin from the overlap event needs to go into the cast to BP_Flashlight

more ▼

answered Dec 24 '17 at 02:11 AM

avatar image

1k 64 48 98

avatar image Pachyderm Dec 24 '17 at 03:21 AM

avatar image TaunTButtoN Dec 24 '17 at 04:01 AM

But then wouldn't you cast your BP_Flashlight to a BP_Enemy which would fail. I think you need to take the "Other Actor" pin from Event ActorBeingOverlap and put that into the Object for Cast to B_Enemy

avatar image Vizgin Dec 24 '17 at 04:31 AM

You're absolutely right TaunTButtoN. He's passing a wrong object into his Cast node as well. Thanks for pointing that out.

(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