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"

Can you detect the direction of a collision?

Hello all, first post! So i've just started with Unreal and i'm following along on the Virtus Learning Hub RPG Series and this video basically gets your character throwing a spell projectile. I'm trying to modify mine to create an AOE "explosion" and the particle emitter i've selected has a directional blast effect and its location is spawning just fine:

alt text

However, i want the explosion to be rotated to match whatever surface it collides with if it hits a static mesh, like a wall or some hilly terrain:

alt text

I've been searching everywhere and none of my methods are working. I've already set the emitter to use local space, because originally i tried hard-coding rotation and even that wasn't working, so i know my explosion CAN rotate, i'd just rather not have to hard-code every rotation. Assuming the green arrows are my projectile's velocity, how do i solve for the red arrow, or the direction of collision?

alt text

Product Version: UE 4.19
Tags:
more ▼

asked May 26 '18 at 11:18 PM in Blueprint Scripting

avatar image

EinMcDrummies
1 2 3

avatar image EinMcDrummies May 26 '18 at 11:35 PM

So i just had an idea but i'm unsure if it is the correct solution, how to implement it, or will work at all. Could i use a line trace? I could potentially cast it starting at my spheres location and have the end follow its velocity forwards to determine what it's colliding with. I just don't know what kind of info a linetrace returns. does it return something like a normal? I'll be working on this until someone says otherwise.

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

2 answers: sort voted first

So I actually just solved this, and i'll drop my method here for everyone to tell me how overboard i went lol.

After pulling my hair out for the past few hours, i figured out kind of what the problem was. Here's my solution:

Here, I'm doing what i suggested to myself earlier and starting a linetrace from the position of my collision sphere, TO that location plus some velocity (predicting its path) to find out exactly where it will collide. Its OutHit> gave me the rest of the data I needed. alt text

Getting it's spawn location was easy. Finding it's rotation was driving me nuts becasue it kept orienting in completely random ways and I couldn't figure out why. I knew it was going to be a look-at of location and normal. Basically through writing values to the screen, i figured i needed to rotate my blast -90Y degrees and THEN add it to the normal (still unsure why, but it works). alt text

I wasted all day on this, and there's probably a simpler method, but it's done. alt text

solved1.gif (398.9 kB)
solved2.gif (398.2 kB)
solved3.gif (578.8 kB)
more ▼

answered May 27 '18 at 02:33 AM

avatar image

EinMcDrummies
1 2 3

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

When a hit occurs, you have a node, BreakHitResult. In this node are four vectors, Location, Impact Point, Normal, and Impact Normal.

Rotating the projectile to the surface would be Impact Normal. And this would occur at the Impact Point.

Keep in mind that Location is the level location of the actor that was hit, and is not necessarily where the projectile hit.

alt text

breakhitresult.png (26.3 kB)
more ▼

answered May 27 '18 at 02:10 AM

avatar image

Doctor_Kannon
196 4 3 11

avatar image EinMcDrummies May 27 '18 at 02:38 AM

Thanks! I basically did the same thing with a linetrace because i don't really know what the difference is between OnHit and OnOverlap, which is what I was using. For some reason my collision wasn't firing of all the time with the OnHit event.

(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