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"

Node for detecting if actor is colliding

I am having some difficulty with collisions, I have an actor that i can drag around the screen with the mouse and I need a way to check if it is colliding with something. Currently it seems the only methods of collision detection in blueprint are via event nodes. I need a way to check if the current actor is colliding with anything as a node, not an event, so I can add logic to this. (e.g. if isColling apply red texture else apply green texture).

Additionally my actor won't trigger onHit or on actor overlap events. I am using the shape_cube starter content mesh in my blueprint as a static mesh component, made sure all the collisions were set up to block all as type world dynamic. And when I move the actor I use set actor transform with the sweep option set to true. Am I missing a step?

Product Version: Not Selected
Tags:
more ▼

asked Jan 12 '15 at 12:54 PM in Blueprint Scripting

avatar image

lunix
81 14 22 25

avatar image Furroy Jan 12 '15 at 02:13 PM

I would make an integer variable IsColliding default to zero. Make an event handler for OnBeginOverlap and increment IsColliding, and an event handler for OnEndOverlap to decrement it. Then elsewhere in your code you can just check if IsColliding is zero to know if it is overlapping anything at that moment.

avatar image lunix Jan 12 '15 at 02:20 PM

This sounds like a really good solution. My question though, doesn't On Begin Overlap only check for other actors or will it check all collision?

avatar image Erasio Jan 12 '15 at 02:33 PM

It will check for everything which does overlap with your actor. Keep in mind that both actors (or meshs or whatever) have to have the "Generate overlap events" and have to overlap the group of your actor (with either overlap or block) in the collision settings.

avatar image Furroy Jan 12 '15 at 02:46 PM

It can be quite fiddly to setup up what exactly will trigger an overlap vs what won't. So mess around with that to see what works for your use case. Also in your overlap events you can try to cast what it overlapped with and then only inc/dec your counter if it's run into something you care about and ignore the rest. Just make sure to do the exact same checks in both start and end events!

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

1 answer: sort voted first

On hit will only trigger if you have "Generate Hit events" on which is a check box right above the actual collision sets.

Additionally you will have to make sure that all other actors have in their collision settings overlap or block set under "world dynamic".

To check for collision you would usually do a line trace (this is a node). You provide a start point and an end point and it will basically draw a line between those two. If it happens to hit something while doing this it will provide a hit result which you can break to get the actor it collided with, where it hit something, what normal it had and a few other things.

I hope this helps.

Cheers

more ▼

answered Jan 12 '15 at 01:29 PM

avatar image

Erasio
5.9k 291 86 293

avatar image lunix Jan 12 '15 at 01:43 PM

I know how to do a line trace, but how would I use that check if actor X is colliding with anything? A line trace would only tell me if there is an object in a line from the actor, but that wouldn't account for the actor's collision bounds.

Edit: thank you for the collision advice though, I will try that and see if it helps

avatar image Erasio Jan 12 '15 at 02:10 PM

You can do all different kinds of stuff with it.

If you move it you can beforehand check if there is something and if it should move at all.

Changes like applying a different material are actually better done using events so are most other things which should consider the whole collision body.

I just tried to be as general as possible in case you didn't know about it and it'd magically solve something ;)

(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