# Line trace based on reflection (bounce)

sorry I am an idiot… I should have said
impact normal + (impact normal - the angle of you trace )

Hi. The formula should be R = 2*(V dot N)*N - V according to what I have read. See 3D Programming - Weekly : Reflecting a Vector

I attempted to change it to what you wrote, but it didn’t give me correct results unfortunately.

Hi potoo,

This isn’t based off of the projectile but instead it’s based directly off of the player view. See if it gives you any ideas. The ‘Mirror Vector by Normal’ might do the trick.

Cheers,

TJ

this code is working for me except it don’t reflect correctly in the -X world direction
In that direction it reacts like the normal is fliped, then instead of reflecting it refracts

I tested this in 4.6.1 but I couldn’t get your results. Which version of the editor are you using? Also, take a look at this tutorial I posted just to make sure everything is the same.

I’m using 4.6.1.
actually the problem is when the line trace hits a normal in 1,0,0 direction ( it not about the world)
But I’ve made a reflection by normal that is working for me (it was a hell to do this since I’m not a programmer)
I think is a bug because I saw other users reporting the same problem.
below the code:

I’m glad your custom function got this working for you. If you have time could you try this function instead and let me know if it also works correctly or if you experience the error again?

Hi! I’ve tested it and (I think) the behavior was the same of the default “mirror vector by normal” node. the error persists.
this setup was the same I did, only inverted the order of the multiply.

I don’t know why but when it calculates against the 1,0,0 normal it refracts so I multiply to -2 instead of 2

Edit: I tested and the setup I made didn’t worked in other conditions (different position) this is making me crazy
maybe if I make a video showing the problem you can helpme?

I know you’re in 4.6.1 now, but did you upgrade your project from an older version of the editor? The reason I ask is on further testing, my original setup works correctly in a new 4.6.1 project but I noticed that I get the same results as you in a older 4.5.1 project I have.

I don’t remember really well but maybe even before 4.5.1.

thank you so much for testing that you are awesome.

there’s any way to fix this?

Okay, here are a couple possible solutions. Both fixed the issue for me in 4.6 but not 4.5.

Add the Normal and Impact Normal of the previous line trace and use that info to set the Start of the next line trace.
28166-
Or make an Array out of the Hit Actor and have the next line trace ignore that actor.
28167-
Let me know how they go.

I’ve also logged this as JIRA UE-8434 in our tracking software. So our devs will be looking into this issue as well.

I tested booth solutions. but still it has the same problem.
very odd…
thanks for submitting this for fix

I’ll try again when I got home. I’m thinking… maybe it stopped working because I put the results of the line trace to a variable and traced the next line with the variable.
I really have the impression that when I first tested the tjballard solution it have worked

Same here. I think we have the same issue/bug.

I’m considering moving the project to a fresh 4.6 version to see if it resolves it. My current project has been upgraded a couple of times (from 4.3 i think) and is now 4.6.

I will also try gustavorios2’s workaround.

Thanks for all the replies/help so far!

The JIRA report came back as not being a bug. The developers said that the correct way to handle this setup is to use the first fix I posted above. You shouldn’t directly line trace off a a surface normal, you need to add that small offset to keep errors from happening.

However, there still seems to be issues with older converted projects. I believe recreating them in 4.6 will fix the issue and upgrading from there works correctly (tested with our latest internal build).

Here is a tutorial I posted with those changes.

On a new empty project everything works fine though…
I tried to create a new project and copy the game folder from the older project to the new but the line trace problem came with it

Since it’s only a few nodes. What if you remove the ricochet blueprint setup from the old project, migrate the content, then recreate the ricochet blueprints again in the new project?

that didn’t worked either… Well now at least I know that problem is because I upgraded my project. I’ll just work on other parts of the game and hope that in a future version it will work

Hi! I am trying to do something similar but with lasers (reflected using prisms). How can I do this bounce logic x times, depending on the amount of prisms. Say if there is one prism then the beam should reflect once, but if there is a second after the reflected beam, I want it ti be REFLECTED of the normal once again. Can I use custom events and line trace start point as paramater input for this?

Thanks