# Using Reflection Vectors on a actor

**URL:** <https://forums.unrealengine.com/t/using-reflection-vectors-on-a-actor/458818>\
**Category:** Blueprint\
**Tags:** unreal-engine, UE4, Blueprint, question\
**Created:** [November 25, 2019, 5:06pm UTC](https://forums.unrealengine.com/t/using-reflection-vectors-on-a-actor/458818 "2019-11-25T17:06:54Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Reetro\_69](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Reetro\_69](https://forums.unrealengine.com/u/Reetro_69)\
**Post date:** [November 25, 2019, 5:06pm UTC](https://forums.unrealengine.com/t/using-reflection-vectors-on-a-actor/458818/1 "2019-11-25T17:06:54Z")

</div>

Hello my question is about using reflection vectors on an actor. My basic idea is shown this example.

 ![292966-example.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/1/0/110c994a2f686e4940461be9571720a4928cfed4.png)

I have basic code in place for this tho it’s pretty buggy atm here is that code.

 ![292967-update-direction.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/9/6/296eddb433dde4d394a500dce696f8b8e605fea9.png)

And to move the actor am doing this

 ![292968-timeline.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/7/f/e7fb25b5b73e42285c553b2a7f958076c86f04b7.png)

This is inside a looping timeline which add’s movement input to the actor. This all ends up being pretty buggy and doesn’t always working here is video showing how it currently is [Sort of Working Reflection Vectors - YouTube](https://www.youtube.com/watch?v=Zz9-yknpgXY) as you can see in that video the direction doesn’t always update. So any suggestions on how I can improve this?

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [November 25, 2019, 8:33pm UTC](https://forums.unrealengine.com/t/using-reflection-vectors-on-a-actor/458818/2 "2019-11-25T20:33:06Z")

</div>

I’d do it with line traces. Do a trace to decide where it’s going to hit and then just lerp with a timeline ( or tick with vinterp ) from where you are to where you’re going.

The repeat the process.

It really depends how complicated it’s going to get. If there’s gonna be lots of objects hitting each other, there may be a better way…

---

<div class="post-metadata">

**Author:** ![Reetro\_69](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Reetro\_69](https://forums.unrealengine.com/u/Reetro_69)\
**Post date:** [November 26, 2019, 2:53am UTC](https://forums.unrealengine.com/t/using-reflection-vectors-on-a-actor/458818/3 "2019-11-26T02:53:49Z")

</div>

I feel like I set this up wrong here is the end result of what I did [Linetrace end result - YouTube](https://youtu.be/ywq5C4NNwpc)  
and here is my code  
Event Graph

 ![293004-event-graph.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/5/b/a5be350e02f8c2c081fe3804440d8e51df86b13a.png)

My Get reflection function

 ![293005-getrefection.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/b/e/ebe0b4684c685794bfeb8328a92749fd4d071ef7.png)

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [November 26, 2019, 3:45pm UTC](https://forums.unrealengine.com/t/using-reflection-vectors-on-a-actor/458818/4 "2019-11-26T15:45:40Z")

</div>

It basically seems to be ok ( hard to tell what the angles are in you vid ).

But the actor needs to travel to the intersection point first, then the next one etc…

---

<div class="post-metadata">

**Author:** ![Reetro\_69](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Reetro\_69](https://forums.unrealengine.com/u/Reetro_69)\
**Post date:** [November 26, 2019, 4:08pm UTC](https://forums.unrealengine.com/t/using-reflection-vectors-on-a-actor/458818/5 "2019-11-26T16:08:38Z")

</div>

Hey thanks for the help I just found a really simple solution for this. First thing I did was add a ProjectileMovement for easier movement. Next I made a c++ function that does this `float DotProduct = FVector::DotProduct(VectorToReflect, Normal);

FVector NewVector = 1 \* -2 \* DotProduct \* Normal + VectorToReflect;

return NewVector;` Every time a bullet hits a wall this is calculates it’s reflection. All I gotta do is input the hit normal and the velocity it’s traveling at example here

 ![293030-example.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/e/4/7e4922d4c18521f3415c995a62f43b670c58aca8.png)

And the end result is this

[![](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/0/5/705fe59e89f62cf2446e0e9d8b64e25aae0047ba.jpeg "Working Reflection Vectors") ](https://www.youtube.com/watch?v=31z54haUKo8)

Anyway thanks for the help

---

<div class="post-metadata">

**Author:** ![cyb201](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/cyb201/32/956468_2.png) [@cyb201](https://forums.unrealengine.com/u/cyb201)\
**Post date:** [March 16, 2024, 12:41pm UTC](https://forums.unrealengine.com/t/using-reflection-vectors-on-a-actor/458818/6 "2024-03-16T12:41:00Z")

</div>

Hello, I’m sorry to reopen this topic.I followed your tutorial to operate, but in any case, the bullet only bounces back from the opposite direction of velocity rather than reflecting like light.Can you provide more detailed functions?
