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"

How can I get the surface normal's rotation in collision?

EDIT: Answer posted.

Hello,

I have a projectile that I have made stick to walls, currently behaving like the Medic's needles from TF2 (sticking to walls at any angle it hits).

I would like to change it so that it will be perpendicular to the surface, AKA aligning to the surface normal rotation. I'm not sure how to go about getting that kind of data using Blueprint.

I've tried searching a variety of keywords in the context-sensitive menu by dragging a wire from the outputs of the "OnComponentBeginOverlap" node, but I can't seem to find the data I'm looking for.

What would be a good way to go about doing this? Or doing something like applying a bullet hole decal after a ray trace? (which I assume also involves aligning to surface normal).

Product Version: Not Selected
Tags:
more ▼

asked Apr 07 '14 at 10:18 PM in Blueprint Scripting

avatar image

nopunintendo
405 11 18 36

avatar image Jacky Apr 07 '14 at 10:24 PM

I dont know much about how a projectile is set but line trace gives you the hit surface normal information when you break hit result so you may want to look into that.

avatar image nopunintendo Apr 07 '14 at 10:31 PM

Hm, if returning surface normal info is unique the line trace, I may just have to do a short line trace after my overlap event fires. Thanks for the tip, I'll look into that.

avatar image nopunintendo Apr 15 '14 at 03:49 AM

I found what I was looking for. I should have been using the OnHit event instead of the OnBeginOverlap event. OnHit returns hit info with normals and impact etc.

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

1 answer: sort voted first

I've found the solution to calculating the angle of impact in blueprint, so I thought I'd come back here and post it for anybody who finds this question.

theta(angle between vectors a & b) = acos( dot(a,b) )

alt text

So here I use a Dot Product node, and input the forward vector from my projectile, and the impact normal of the hit result (from a trace or hit event). Then I take the Acos(degrees) node to output the angle in degrees.

That's it!

Then (if the angle is valid) to rotate the projectile to match the surface normal rotation at the location of impact, I first move the projectile to the point of impact, then use the Find Look at Rotation node to rotate the projectile to face the wall.

To make it look like the projectile sticks, you will also have to disable any movement and physics.

alt text

angleofimpact.jpg (44.7 kB)
angleofimpact2.jpg (118.6 kB)
more ▼

answered Aug 21 '14 at 05:14 PM

avatar image

nopunintendo
405 11 18 36

avatar image nopunintendo Aug 21 '14 at 05:29 PM

What I did to get my hit result was to trace a line every frame from my projectile's location, towards its forward vector a short distance until it hit something.alt text

linetrace.jpg (111.5 kB)
avatar image Jacky Aug 21 '14 at 05:32 PM

Thanks for posting your solution!

avatar image Loki8Toki Nov 18 '15 at 10:33 AM

dbInteractive Thank you very much for posting the solution !!! even after a year and a half that so helped !!! Thanks again !

avatar image nopunintendo Nov 18 '15 at 02:44 PM

No problem! I'm very happy to help.

(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