# Swaying light

**URL:** <https://forums.unrealengine.com/t/swaying-light/398747>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine\
**Created:** [June 14, 2017, 3:19pm UTC](https://forums.unrealengine.com/t/swaying-light/398747 "2017-06-14T15:19:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kengi9](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Kengi9](https://forums.unrealengine.com/u/Kengi9)\
**Post date:** [June 14, 2017, 3:19pm UTC](https://forums.unrealengine.com/t/swaying-light/398747/1 "2017-06-14T15:19:19Z")

</div>

Hello!

I have the basic lamp from the starter set and I wanted to make the light source sway around a little bit by just having the object rotate on the x axis. In my flow I have tried to outline what I’m logically trying to do. So when the player approaches the area I call the function SWAY, which then looks to see if ticker is true (player is on the box collider) then it checks if Upswing or DNswing is true. For ease I thought I would set UPswing to true and DNswing to false, so that the object always starts swinging towards the positive side of the x axis. I then want this object to swing WHILE under 10 degrees, once it hits 10 degrees, than I want DNswing to be true and it will go until -10 degrees.

I can get the object to move, but I haven’t been able to do it smoothly, it will go 10 degrees positive and then restart back at 0, or completely crash. I think I must have something wrong with my logic with While Loops (As I tend to always have issues with them). If I was coding I might do a FOR Loop, i=0; i\<11, i++ something like that, but I’m not sure how to do that in blueprints.

If anyone has suggestions it would be appreciated!

 ![200595-capture.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/7/1/e71a624d080fb49da6d2d9fe6681383b37ec012c.jpeg)

---

<div class="post-metadata">

**Author:** ![Kvothe218](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Kvothe218](https://forums.unrealengine.com/u/Kvothe218)\
**Post date:** [June 14, 2017, 3:39pm UTC](https://forums.unrealengine.com/t/swaying-light/398747/2 "2017-06-14T15:39:55Z")

</div>

Hey Kengi9,

To begin with, there are a few issue with your blueprint, but instead of debugging those, I would strongly recommend a Timeline in this situation. It would take care of a lot of your logic without the complexity of your current blueprint. If you aren’t familiar with them, there’s a great tutorial on using a timeline for a door that you can adapt to fit this situation.

Give this a look:

> **[A new, community-hosted Unreal Engine Wiki](https://forums.unrealengine.com/t/a-new-community-hosted-unreal-engine-wiki/141494)**
>
> After over a year in maintenance mode, the official Unreal Engine Wiki is now permanently offline. These resources now live on a new community-run Unreal Engine Community Wiki — ue4community.wiki! You will be able to find content from the official...

~K

---

<div class="post-metadata">

**Author:** ![Kengi9](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Kengi9](https://forums.unrealengine.com/u/Kengi9)\
**Post date:** [June 15, 2017, 5:38pm UTC](https://forums.unrealengine.com/t/swaying-light/398747/3 "2017-06-15T17:38:20Z")

</div>

That worked, PLUS I learned about timelines! Cheers!! Thank you so much!
