x

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. 

Detect collisions on BeginPlay

In the game I'm working on it's possible for an actor to spawn on top of the player and I'm looking for a way to detect that and move the player out of the way. I know you can tell the SpawnActor function to adjust the spawn position if there's a collision but the nature of the game means we don't want to adjust the position of the newly spawned actor but rather move the player out of the way.

I was hoping either an overlap or on hit event might happen when the new actor is spawned and I could detect things that way. Unfortunately overlaps don't seem to happen when the 2 components would block each other and hits don't happen if you aren't moving. So my player just gets stuck in the middle of the new actor and can't move.

What would be the best way of detecting an actor has spawned on top of another actor? Thanks.

Product Version: UE 4.11
Tags:
more ▼

asked Jun 29 '16 at 11:00 PM in Everything Else

avatar image

kgamble
919 40 60 204

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

2 answers: sort voted first

I decided to just go through all the functions available to me on my actor and its root component to see if anything looked like what I needed. UPrimitiveComponents have the "ComponentOverlapMulti" function which does exactly what I want. I called that on my root component, passing in the position and rotation of my actor and that gave me a list of anything it overlapped with and whether the overlap was blocking or not. Then I just filtered looking for any of my characters that might be colliding with the new actor. If you only need to look for one specific actor you can also just use ComponentOverlapComponent and pass in the RootComponent of the actor your checking along with its position and rotation.

more ▼

answered Jun 30 '16 at 06:25 PM

avatar image

kgamble
919 40 60 204

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

kgamble, I too have been frustrated that overlap events don't get triggered automatically if two actors start out overlapping. But you can use the "Is Overlapping Actor" blueprint node to explicitly check whether two things are overlapping. So right after spawning your actor, use this node to test whether it overlaps with your character and if it does, move your character somewhere else (the logic for this is up to you to implement).

more ▼

answered Jun 30 '16 at 12:49 PM

avatar image

Krxtopher
825 27 15 56

avatar image kgamble Jun 30 '16 at 06:19 PM

Unfortunately IsOverlappingActor just checks the list of overlapping components and since I'm looking for blocks rather than overlaps that doesn't work for me. Thanks for the suggestion though.

(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