How to move an object in a sine/wave pattern?

So I understand how to move an object across the screen in a straight line (and either up or down), but I’m not really sure where to begin having it also oscillate up and down, as if following a sine wave. Is this something that needs to happen with the Math node or does it have to have a predetermined path to follow?

For this matter, I’m also not sure how to move things in ‘patterns’, such as going in a circle, or an NPC pacing a route. I only understand how to make things go one way indefinitely, which is rather limiting haha.

There are any number of ways to do different movements. A simple example of a sine wave movement is this:

It just gets the starting location on init and stores that in a property, then on every frame it will take the sine of the time and adds that to the starting Z location.

For going in a circle, you could either use the equation that defines a circle to move it around a point, or you could make it the child of a rotation point object and just rotate the rotation point so that the child moves around it in a circle.

I haven’t had something follow a path before, but you could use the Vector Mix node to move an object smoothly back and forth between two points.

Again, there are lots of options and if you have another situation you would like a specific example on, you could ask about that, but there is a sine wave example. :slight_smile:

3 Likes

Thank you! I think trying and deconstructing/reconstructing this will really help my understanding of the process :smiley:

2 Likes

I’m just gonna put this here for my own future reference. The sine movement worked beautifully, but I was having trouble figuring out how to also make it move in another direction at the same time (have it move up and down in a sine wave while also moving across the screen on the x-axis). I’m used to using the translate object nodes, but that didn’t have any effect and the cube would just go up and down without moving to the right. Finally figured out that the time node is what is updating the set location node. Therefore, this setup makes the object go up and down in a sine pattern as well as move across the screen at the same time.

Sidenote: making an object move in a tangent pattern is oddly amusing, what a fun function! :grin:

1 Like