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:
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:
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?
asked May 26 '18 at 11:18 PM in Blueprint Scripting
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.
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).
I wasted all day on this, and there's probably a simpler method, but it's done.
answered May 27 '18 at 02:33 AM
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.
answered May 27 '18 at 02:10 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here