Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How could you make a bobbing "animation" for an object?

I have floating swords with SurfaceGUIs in front of them that the player can interact with to buy and / or sell, but right now they feel kind of static just sitting there (and being anchored). To give more life and movement to them, I wanted to program something that would make them bob up and down so they would be "floating".

Looked into it for a bit and would assume it has something to do with CFrame but I couldn't find a definitive answer and I couldn't figure out how to do it myself. Any pointers people could give me would be appreciated.

tl;dr I want to make something bob up and down as if its floating but cant find out how to do it myself. Need a shove in the right direction.

If you have any questions please feel free to ask in the comments.

3 comments

0

"assume it has something to do with CFrame", I just stated the obvious rip

0

you can tween them if they are a single object

0

OOOOOOOOoOOoF, I forgot that existed, thanks for the answer!

1 answer

Inside anything that is called per frame you can use this formula:

local pos = Origin + Vector3.new(0, math.abs(math.sin(P + DT * S) * amplitude), 0)
--// where p is phase, dt is deltatime, and s is speed.
--// i had this formula saved from the devforum.

You can also use TweenService to gradually move it up and down.

This discussion is preserved as it was. New answers, comments, and votes are closed.