# Reflections

#### Noah

##### Well-known member
I need to know how to do reflections for an upcoming project I have in mind.

Solution
Like, vector reflections?

So, lets say you have a laser; a beam. You have an object; a surface. So, this surface has a direction: this is called the surface normal. If there were to be a panel that is facing straight upwards, its surface normal would be the vector <0, 1, 0> (it has no x or z, only y upwards/downwards).

So, we have the surface normal. There is a setvar action "ReflectVector" under Vector Manipulation. It has an output and 2 parameters: Initial Vector (the vector of the beam), and Normal Vector (the surface normal).

Let's say the beam's vector is <1, -1, 0>. Putting this into ReflectVector with the surface normal as the other parameter should return <-1, -1, 0>. This isn't actually reflected across the...

#### stinkey

##### Well-known member
Like, vector reflections?

So, lets say you have a laser; a beam. You have an object; a surface. So, this surface has a direction: this is called the surface normal. If there were to be a panel that is facing straight upwards, its surface normal would be the vector <0, 1, 0> (it has no x or z, only y upwards/downwards).

So, we have the surface normal. There is a setvar action "ReflectVector" under Vector Manipulation. It has an output and 2 parameters: Initial Vector (the vector of the beam), and Normal Vector (the surface normal).

Let's say the beam's vector is <1, -1, 0>. Putting this into ReflectVector with the surface normal as the other parameter should return <-1, -1, 0>. This isn't actually reflected across the surface normal, however. We have to multiply this resultant vector by -1 to get the actual reflected vector.

This resultant vector, multiplied by -1, is the new direction of the beam.

If you wanted to do something like a mirror, you would have to shoot out multiple beams from the player's eye location, bounce them off any reflective surfaces, until they hit a light emitter or a solid object.

#### DFIdentity

##### Support
Support
ik this is late but. i love you

#### Vulcanowo

##### Well-known member
DF has not added that. IDK how you would recreate Java's reflections in DF smh.