Math For A Spinning Tornado System

The goal is the video attached to the post.

I am confused about the math and Roblox physics used to make the object orient around its own pivot point, as well as have its position orbit around the pivot point of the tornado.

If you know how to do this, please reply with math/the Roblox object used to do this.

1 Like

I was gonna write out the code but it would be hard to know how you would use it so ill just explain the steps.

  1. Get the relative position (object - tornado) and note the distance (on the x and z axes) at the start
  2. Get the angle of the object relative to the tornado (use atan2 with x and z of the relative position)
  3. Have a while loop that waits for the renderstepped each iteration that ends after a time limit or connect to renderstepped (and make sure to disconnect after time limit)
  4. Calculate the distance (with interpolation) and angle at the current time
  5. Update the object CFrame by first converting the polar coordinates back in to cartesian coordinates with sine and cosine and the current distance and lastly add CFrame angles to manipulate the object along its own pivot point

Another option if you want a more Roblox-physics approach is to have the tornado-part spinning using a AngularVelocity, then add a attachment with an offset. Lastly, have objects get picked up by the tornado by using a AlignPosition and have their target be the attachment.

Here’s a top-down sketch of how it would look:
TornadoSpin

just cframe it like this:

local RunService = game:GetService("RunService")

local originPoint = workspace.OriginPoint
local spinPoint = workspace.SpinPoint

local eTime = 0
local radius = 10
local amplitude = 5
local function tornadoEffect(step)
	eTime+=step
	local yPosition = math.sin(eTime) * amplitude
	local currentRadius = radius + yPosition
	local displacement = eTime * (math.pi * 2)

	local displacementVector = Vector3.new(math.sin(displacement) * currentRadius, amplitude + yPosition, math.cos(displacement) * currentRadius)
	spinPoint.CFrame = originPoint.CFrame + displacementVector
end

RunService.Heartbeat:Connect(tornadoEffect)

Video:

rbxm file vvv (drag and drop into studio)
TornadoThing.rbxm (5.7 KB)

1 Like

What do you mean by that? I am confused.

what the heck did i just walk into

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.