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"

Line trace based on reflection (bounce)

I have a shoot mechanic that launches a physics ball that can bounce on the level collision (it is basically the FPS template ball). In relation to this I want to create a preview of the bounce trajectory. The idea is to use the trace to let the player know what direction the ball will bounce, before he actually launches it.

Later I will switch out the trace with a mesh (my "preview line") and transform it using the values currently passed to the trace's end-input. Until then I have used the trace to get the basics right.

Obviously there will be an error margin as the trace/line will not care about the physics (velocity and shape). I'm planning to accomodate for the velocity by using the charge values as criterias for the trace length etc. I will add the trace/preview to a tick event once I see that it is acceptable.

As you see in the video: https://www.youtube.com/watch?v=pIM19IINkCA

it is not working correctly. It seems like trace #2 is being done from the mesh normal rather than the reflect vector. I guess my math is incorrect here.

My questions are:

  1. Any thoughts on why this is not working?

  2. Suggestions for better ways to do this? If possible.

Here is my blueprint. alt text

Product Version: Not Selected
Tags:
more ▼

asked Jan 18 '15 at 01:52 PM in Blueprint Scripting

avatar image

GreasyExcretion
47 4 7 15

avatar image Hexmare Jan 18 '15 at 05:37 PM

I am by no means an expert.. But wouldn't you be looking for the (impact normal - the angle of you trace ) * -1

This way the angle of reflection will change based on your angle of attack?

avatar image Hexmare Jan 18 '15 at 05:48 PM

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

avatar image GreasyExcretion Jan 21 '15 at 02:57 PM

Hi. The formula should be R = 2*(V dot N)*N - V according to what I have read. See http://www.3dkingdoms.com/weekly/weekly.php?a=2

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

Thanks for reply!

(comments are locked)
10|2000 characters needed characters left

2 answers: sort voted first

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.

alt text

Cheers,

TJ

ricochet01.jpg (132.2 kB)
more ▼

answered Jan 21 '15 at 08:30 PM

avatar image

TJ V ♦♦ STAFF
41.2k 1009 183 493

avatar image gustavorios2 Jan 25 '15 at 02:35 AM

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 alt text

243535345454.jpg (1.3 MB)
avatar image TJ V ♦♦ STAFF Jan 26 '15 at 07:50 PM

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.

avatar image gustavorios2 Jan 26 '15 at 08:33 PM

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: alt text

2313441123.png (340.8 kB)
avatar image TJ V ♦♦ STAFF Jan 26 '15 at 09:42 PM

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?

alt text

avatar image gustavorios2 Jan 26 '15 at 10:56 PM

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?

avatar image TJ V ♦♦ STAFF Jan 27 '15 at 02:26 PM

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.

avatar image gustavorios2 Jan 27 '15 at 02:30 PM

yes! I upgraded many times... 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?

avatar image TJ V ♦♦ STAFF Jan 27 '15 at 10:06 PM

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.

alt text

Or make an Array out of the Hit Actor and have the next line trace ignore that actor.

alt text

Let me know how they go.

avatar image TJ V ♦♦ STAFF Jan 27 '15 at 10:46 PM

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

avatar image gustavorios2 Jan 28 '15 at 11:56 PM

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

avatar image GreasyExcretion Jan 29 '15 at 11:25 AM

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!

avatar image gustavorios2 Jan 29 '15 at 01:07 PM

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

avatar image TJ V ♦♦ STAFF Jan 29 '15 at 03:29 PM

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.

https://wiki.unrealengine.com/Simple_Line_Trace_Ricochet

avatar image gustavorios2 Jan 29 '15 at 03:34 PM

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

avatar image TJ V ♦♦ STAFF Jan 29 '15 at 06:02 PM

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?

avatar image gustavorios2 Jan 30 '15 at 12:17 AM

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

(comments are locked)
10|2000 characters needed characters left

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

more ▼

answered Mar 21 '18 at 04:01 PM

avatar image

9robin3
31 1 4 10

(comments are locked)
10|2000 characters needed characters left
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