Swaying light


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!

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:


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