Announcement

Collapse
No announcement yet.

Issues with reflecting line trace.

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Issues with reflecting line trace.

    Hey there! I've joined a small game jam to try and scratch the rust off of my game dev skills.

    So my game idea is somewhat simple, 3D puzzle game focused around redirecting spells shot from a wizard to hit a switch on the other side of the room. I've got the reflection of a ray trace working, and I suspect it would work perfectly for fireballs and the like, but I will need ray tracing for a lightning spell, and I'm running into an issue with reflecting mirrors back on themselves. I probably wont design any puzzles to require reflecting mirrors at each other, but it causes issues that the final user of the game may run into (such as rotating mirrors to a new position and crossing paths with the mirror reflecting the current ray to it... it's kind of hard to explain. I'll get a video of it happening.

    Here's a video of the reflections working.

    And here's what happens if you reflect a mirror back on the mirror that's firing at it.

    As you can see it sort of loses all the tracing going towards it, and only can regain it if I wiggle the other mirrors around a bit and fire the ray trace at it again.

    Here's the initial code I use to get the wizard to fire the trace. (I set the firing boolean to true in the character controller when the space bar is pressed.)

    Click image for larger version

Name:	d5cab917b16f044ee65567af724a53b4.png
Views:	1
Size:	420.8 KB
ID:	1221367

    Here's the code I use to get the mirrors to reflect.

    Click image for larger version

Name:	c958606b613070a5d327959e6767ce0f.png
Views:	1
Size:	459.3 KB
ID:	1221368

    I'd sincerely appreciate anyone's help. I have a feeling that the raytrace hit event on the mirrors is only able to handle one trace at a time, but all edits I've made to it to try and incorporate an array of hits has failed. I really want to be able to stop bumping my head against the wall on this and move on to something else.

  • #2
    You can condense the two separate events that you have by using a recursive function call and passing the reflected normal into the new function.

    I would make a new surface type called "Mirror" and allow reflection based on that. The mirror surface would have a material applied that uses a physical material, which uses the Mirror surface type.



    EDIT: I goofed on the above Blueprint. Should be a line trace instead of a capsule trace.
    Last edited by ausernottaken; 06-04-2017, 04:40 AM.

    Comment


    • #3
      This looks really promising! I'll give it a proper test when I get home from work. Thank you so much for the suggestion!

      Comment


      • #4
        It works like a charm! Thanks again!

        Comment

        Working...
        X