# Wanting to move and rotate a material based on distance from player

**URL:** <https://forums.unrealengine.com/t/wanting-to-move-and-rotate-a-material-based-on-distance-from-player/273593>\
**Category:** Community & Industry Discussion\
**Tags:** unreal-engine\
**Created:** [January 19, 2022, 8:14pm UTC](https://forums.unrealengine.com/t/wanting-to-move-and-rotate-a-material-based-on-distance-from-player/273593 "2022-01-19T20:14:06Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pipboy3060](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Pipboy3060](https://forums.unrealengine.com/u/Pipboy3060)\
**Post date:** [January 19, 2022, 8:14pm UTC](https://forums.unrealengine.com/t/wanting-to-move-and-rotate-a-material-based-on-distance-from-player/273593/1 "2022-01-19T20:14:06Z")

</div>

I have a straight tunnel made of different segments but I need to bend into the distance .

I know I need to use the “world position offset” node to handle this in the material, but apart from that, I have no idea where to start.

Can anyone give me some pointers, as someone who is just starting out in Material editing and coding? Thanks.

---

<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:** [January 20, 2022, 8:42am UTC](https://forums.unrealengine.com/t/wanting-to-move-and-rotate-a-material-based-on-distance-from-player/273593/2 "2022-01-20T08:42:18Z")

</div>

Can you show the tunnel, or draw a pic of how you want it to turn?

---

<div class="post-metadata">

**Author:** ![Nawrot](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/nawrot/32/618260_2.png) [@Nawrot](https://forums.unrealengine.com/u/Nawrot)\
**Post date:** [January 20, 2022, 10:11am UTC](https://forums.unrealengine.com/t/wanting-to-move-and-rotate-a-material-based-on-distance-from-player/273593/3 "2022-01-20T10:11:43Z")

</div>

This should not be hard (rough version of it) to make.

Get world position, substract from it camera position (you may update that as parameter trough blueprints and dynamic instanced material). Then calculate length of that difference.

And you should have distance

---

<div class="post-metadata">

**Author:** ![Pipboy3060](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Pipboy3060](https://forums.unrealengine.com/u/Pipboy3060)\
**Post date:** [January 20, 2022, 2:52pm UTC](https://forums.unrealengine.com/t/wanting-to-move-and-rotate-a-material-based-on-distance-from-player/273593/4 "2022-01-20T14:52:50Z")

</div>

Like this:

[![](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/9/a/c9adbd655b03825ef9085f02ad6ced8a77ad847d.jpeg "eternal apex") ](https://www.youtube.com/watch?v=guamICykyJg)

---

<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:** [January 20, 2022, 3:26pm UTC](https://forums.unrealengine.com/t/wanting-to-move-and-rotate-a-material-based-on-distance-from-player/273593/5 "2022-01-20T15:26:29Z")

</div>

Isn’t that just perspective?

---

<div class="post-metadata">

**Author:** ![midgunner66](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/midgunner66/32/466711_2.png) [@midgunner66](https://forums.unrealengine.com/u/midgunner66)\
**Post date:** [January 20, 2022, 3:55pm UTC](https://forums.unrealengine.com/t/wanting-to-move-and-rotate-a-material-based-on-distance-from-player/273593/6 "2022-01-20T15:55:16Z")

</div>

The artist who made that has a thread which explains how he did it and has a download to the demo: [Eternal apex // ambient cyberpunk megastructure endless rider](https://forums.unrealengine.com/t/eternal-apex-ambient-cyberpunk-megastructure-endless-rider/112737).  
**Edit:** Oh, but it doesn’t show any of the world position offset stuff…

---

<div class="post-metadata">

**Author:** ![Nawrot](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/nawrot/32/618260_2.png) [@Nawrot](https://forums.unrealengine.com/u/Nawrot)\
**Post date:** [January 20, 2022, 5:50pm UTC](https://forums.unrealengine.com/t/wanting-to-move-and-rotate-a-material-based-on-distance-from-player/273593/7 "2022-01-20T17:50:11Z")

</div>

Everything is described in post he gave link to:

> [@Eternal apex // ambient cyberpunk megastructure endless rider](https://forums.unrealengine.com/t/eternal-apex-ambient-cyberpunk-megastructure-endless-rider/112737):
>
> click for youtube video: (audio is important, and try to watch in 4k fullscreen even if you have a 1080p monitor – the 1080p and lower video is chunky) [[image]](https://www.youtube.com/watch?v=guamICykyJg) eternal apex // an ambient (no goals, just cruising), high speed, futuristic tunnel racer prototype playable prototype on itch: [eternal apex by acatalept](https://acatalept.itch.io/eternalapex) An impromptu game design challenge over a few late nights recently to better wrap my head around: World origin shifting to seamlessly offset player and world geometry every 100…

---

<div class="post-metadata">

**Author:** ![acatalept](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/acatalept/32/465177_2.png) [@acatalept](https://forums.unrealengine.com/u/acatalept)\
**Post date:** [January 20, 2022, 6:18pm UTC](https://forums.unrealengine.com/t/wanting-to-move-and-rotate-a-material-based-on-distance-from-player/273593/8 "2022-01-20T18:18:26Z")

</div>

Actually I don’t think I went into the World Position Offset details in the thread (just World Origin Shifting, another unrelated concept I was trying to tackle) – I had intended to, sorry 😉

I’ll see if I can come up with a breakdown on my specific WPO implementation and add a post in that thread. In the meantime I think this is what got me pointed in the right direction:

> [@How to create a vertex shader similar to Subway Surfers?](https://forums.unrealengine.com/t/how-to-create-a-vertex-shader-similar-to-subway-surfers/12951/11#post1492733):
>
> It flickers because original mesh goes out of camera view, its culled. And I’m not sure what size of mesh should be, make it work perfectly. That material was just an small expreriment. I found it in my archives and checked in 4.19.2 everything works fine. maybe it not really accurate, but for now I don’t have a time to make any imrovements, sorry )) here is material: And how it works: [[Deformed world] ](https://www.youtube.com/watch?v=EAUzrQfhpio) This mesh have size like 1000020001000 UU

Beware that WPO isn’t currently supported by any raytracing tech in UE 4.x, or Nanite/Lumen in UE 5, and may have some other rendering gotchas that I can’t recall off the top of my head (I have pages of notes for that project that I’ll have to sift through).

Good luck!

---

<div class="post-metadata">

**Author:** ![Pipboy3060](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Pipboy3060](https://forums.unrealengine.com/u/Pipboy3060)\
**Post date:** [January 20, 2022, 9:28pm UTC](https://forums.unrealengine.com/t/wanting-to-move-and-rotate-a-material-based-on-distance-from-player/273593/9 "2022-01-20T21:28:21Z")

</div>

> Acatelept himself comes in

IT’S THE MAN HIMSELF!!!

You inspire me acatelept. I eagerly await the possible (but not inevitable) WPO info if you are able to shed some light on it. Your project introduced a lot of concepts to me that I would have never thought about initially, so thank you for posting that thread 🙂
