# How to get the forward vector in a material?

**URL:** <https://forums.unrealengine.com/t/how-to-get-the-forward-vector-in-a-material/361685>\
**Category:** Rendering\
**Tags:** forward-vector, unreal-engine, question\
**Created:** [June 22, 2016, 12:39pm UTC](https://forums.unrealengine.com/t/how-to-get-the-forward-vector-in-a-material/361685 "2016-06-22T12:39:03Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Davision](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Davision](https://forums.unrealengine.com/u/Davision)\
**Post date:** [June 22, 2016, 12:39pm UTC](https://forums.unrealengine.com/t/how-to-get-the-forward-vector-in-a-material/361685/1 "2016-06-22T12:39:03Z")

</div>

The only thing I can find is object orientation and that is only for the up vector. Or am I missing something here?

Setting the forward vector through a dynamic material every tick inside the material would be not a workaround here since that is beside the point of what I’m trying to do.

---

<div class="post-metadata">

**Author:** ![Slavq](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Slavq](https://forums.unrealengine.com/u/Slavq)\
**Post date:** [September 6, 2016, 4:14pm UTC](https://forums.unrealengine.com/t/how-to-get-the-forward-vector-in-a-material/361685/2 "2016-09-06T16:14:08Z")

</div>

+1 I have the same question, any progress on this one? 🙂

---

<div class="post-metadata">

**Author:** ![Davision](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Davision](https://forums.unrealengine.com/u/Davision)\
**Post date:** [September 7, 2016, 12:45pm UTC](https://forums.unrealengine.com/t/how-to-get-the-forward-vector-in-a-material/361685/3 "2016-09-07T12:45:32Z")

</div>

I ended up importing all the meshes I needed it for rotated in a way so that the forward vector becomes the up vector. It is a silly workaround but as long as you only need the forward vector it works that way.

---

<div class="post-metadata">

**Author:** ![Deathrey](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Deathrey](https://forums.unrealengine.com/u/Deathrey)\
**Post date:** [September 7, 2016, 2:16pm UTC](https://forums.unrealengine.com/t/how-to-get-the-forward-vector-in-a-material/361685/4 "2016-09-07T14:16:15Z")

</div>

Why not just local to world transform ?  
If you want object X axis as forward, you could do this:

![](https://d3kjluh73b9h9o.cloudfront.net/original/3X/0/4/04eac1c0a3fc4332e5a785151a3936ef854e4848.png)

---

<div class="post-metadata">

**Author:** ![UnexpectedSquirt](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@UnexpectedSquirt](https://forums.unrealengine.com/u/UnexpectedSquirt)\
**Post date:** [October 1, 2017, 2:20pm UTC](https://forums.unrealengine.com/t/how-to-get-the-forward-vector-in-a-material/361685/5 "2017-10-01T14:20:25Z")

</div>

This method does not appear to work on instance meshes…

---

<div class="post-metadata">

**Author:** ![Deathrey](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Deathrey](https://forums.unrealengine.com/u/Deathrey)\
**Post date:** [October 1, 2017, 11:30pm UTC](https://forums.unrealengine.com/t/how-to-get-the-forward-vector-in-a-material/361685/6 "2017-10-01T23:30:12Z")

</div>

It does, but only in vertex shader( you need to pass the expression on the image above) through interpolator node or custom UV).

---

<div class="post-metadata">

**Author:** ![CodiBasti](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@CodiBasti](https://forums.unrealengine.com/u/CodiBasti)\
**Post date:** [July 25, 2019, 3:43pm UTC](https://forums.unrealengine.com/t/how-to-get-the-forward-vector-in-a-material/361685/7 "2019-07-25T15:43:34Z")

</div>

don’t forget to normalize the transformed vector, if you want to use it as a rotation axis, since it puts a scaling on the output.
