Decal alignment problem

Hi, I want to by using blueprints align my decal when placing them based off of the hit surface impact normal.

In this pic you can see that I have it working good while hitting the floor. The decal should be in the same direction as the white arrow

When I start shooting up a wall this happens:

I’m having trouble compensating the decal orientation and would be happy for any help on it :slight_smile:

I do want to do this with BPs and here is my current nodework in its simpliest form:

the rotation from XVector only seems to work from the floor angles only. Again thanks for any suggestions =)

Hey Devero - just so I understand your blueprint code correctly, it looks like you are determining a vector in which to align the decal. Given that decals project onto surfaces through their -ve X axis, I would suggest the best way to achieve the result you’re after is to find the surface normal of the point you want to align to, and get rotate onto that instead (to ensure that your decal is projected onto the surface correctly).

You should then be able to calculate a rotator for the local-space yaw that rotates the decal’s YZ plane into the correct direction.

I hope that makes sense? I’m happy to elaborate if needed - check out the surface snapping feature in the editor to see how we do this for placement of actors (which includes decals)

Thanks Andrew for the suggestion. Here is the pic of the changed decal projection, Blueprint. I actually tried this first but was unable figure out the Roll value.

So now the decal is projected perfectly onto any surface normal. However, Now I need to rotate the decal to match the direction of my white Arrow by inputting the “Roll” value to the decal. I’m still having issues figuring out the blueprint way to do it.

I appreciate any further help you can provide on this! Thanks!

Hey - I had a shot at this myself - basically if you use the fact that the magnitude of the cross product of two vectors equals the sine of the angle between them { |a x b| = sin(theta) }, you should be able to transform your local-space direction vector into world space, cross this with some world space target vector and get the roll angle from that.

Here’s the Blueprint I came up with for this, hopefully it will put you on the right path:

Thanks for the continued help. I implemented your nodes and it gets just about there. The problem is when you take the arcsine the resultant only accounts for 0-90 degrees. Everything works great if I shoot ingame for only the 0-90 quadrant.

Here is the updated blueprint node

Again I appreciate your help and patience as its so close from working!

Maybe you could try composing a rotator from the angle axis of the cross product? The cross product will flip when it traverses a 180 degree boundary, so it should rotate correctly (provided your two vectors are on the same plane)

Thanks again for the suggestion. I was not able to get that idea to work out. However, I did work on more equations and came up with a solution that works great.

And for anyone interested in my Blueprint

Thanks for all your suggestions!

Hey, could you tell me how you calculated the white arrow direction?

http://i.imgur.com/9Ql7PxP.gif

[http://image.prntscr.com/image/c59a9a0688c74560845f1e14ee747360.jpeg][3]

1 Like

Thanks a lot! I used it to spawn my foot decal on landscape slopes and it works perfectly…even on very steep ones

Thank you! This really helped us out!