To start, I want to make a part essentially orbit around a player’s HRP.
“What do you mean by orbit?”
I want to recreate the motion of the web throw in the Insomniac Spider-Man games.
Example: Web Throw
My problem as stated in the title is that I have little to no clue where to start and how I would go about this, any help would be appreciated. Thanks.
You can try using trigonometric functions to calculate the position of the part at each frame update.
For instance:
local part = -- Reference to the part you want to orbit around the player
local player = -- Reference to the player
local centerOffset = Vector3.new(0, 0, 0) -- Offset from the player's HRP to the center of the orbit
local radius = 10 -- Radius of the orbit
local speed = 1 -- Angular speed (radians per second)
local function updatePosition()
local character = player.Character
if not character then return end
local humanoidRootPart = character:FindFirstChild("HumanoidRootPart")
if not humanoidRootPart then return end
local time = tick() * speed
local angle = time % (2 * math.pi)
local positionOffset = Vector3.new(radius * math.cos(angle), 0, radius * math.sin(angle))
local position = humanoidRootPart.Position + centerOffset + positionOffset
part.Position = position
end
-- Update the position continuously
while true do
updatePosition()
wait() -- Yield to allow other processes to run
end