Help making sonic looping system

I am trying to create a sonic game but I am having a hard time making the loops, I do not understand other peoples post as most of the post posted the the devforum usually result in “I don’t know why you think it is so hard just use body velocity” I need to know a way to do this not just a name of a force.

Hey there, it’s great that you’re enthusiastic about creating a game, but I need to advise against creating a Sonic game on Roblox. Sonic the Hedgehog is a copyrighted character owned by Sega, and any use of its intellectual property, including its name, likeness, and other trademarks, without permission could lead to copyright infringement.

As for the loop itself, I believe you mean the spinning before Sonic is blasted off with speed. Well, for this you need 2 things:

  1. An animation track that spins the player’s character and is also loopable
  2. A script to enable this feature

Once you have your animation, this could should help you:

-- Settings
local SPINNING_LOOP_ANIMATION_ID = "rbxassetid://your_animation_id_here"
local MINIMUM_CHARGE_TIME = 1 -- Minimum time in seconds for the character to charge before taking off
local CHARGE_MULTIPLIER = 500 -- Determines the speed at which the character is launched

local Players = game:GetService("Players")
local localPlayer = Players.LocalPlayer
local character = localPlayer.Character or localPlayer.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local animationController = character:WaitForChild("Animate")
local spinLoopAnimation = Instance.new("Animation")
spinLoopAnimation.AnimationId = SPINNING_LOOP_ANIMATION_ID
local spinLoopTrack = humanoid:LoadAnimation(spinLoopAnimation)

-- Functions
local function startSpinningLoop()
	spinLoopTrack:Play()
end

local function stopSpinningLoop()
	spinLoopTrack:Stop()
end

local function chargeUp()
	local chargeStartTime = os.clock()
	startSpinningLoop()
	return function()
		local chargeDuration = os.clock() - chargeStartTime
		stopSpinningLoop()
		return chargeDuration
	end
end

local function launchCharacter(chargeDuration)
	local velocity = character.HumanoidRootPart.Velocity
	local launchSpeed = math.max(MINIMUM_CHARGE_TIME, chargeDuration) * CHARGE_MULTIPLIER
	velocity = Vector3.new(velocity.X, 0, velocity.Z)
	velocity = velocity + (localPlayer:GetMouse().Hit.lookVector * launchSpeed)
	
	character.HumanoidRootPart.Velocity = velocity
end

local userInputService = game:GetService("UserInputService")

local function onInputBegan(input, gameProcessed)
	if gameProcessed then return end
	if input.KeyCode == Enum.KeyCode.LeftControl then
		local releaseCharge = chargeUp()
		
		local temp
		temp = userInputService.InputEnded:Connect(function(inputEnded, gameProcessedEnded)
			if gameProcessedEnded then return end
			if inputEnded.KeyCode == Enum.KeyCode.LeftControl then
				if typeof(temp)=="RBXScriptConnection" then
					temp:Disconnect()
				end
				
				local chargeDuration = releaseCharge()
				launchCharacter(chargeDuration)
			end
		end)
	end
end

userInputService.InputBegan:Connect(onInputBegan)

This code will launch the player when they hold LeftControl in the direction the mouse is pointing and should be placed as a LocalScript in StarterCharacterScripts.

It is nowhere near perfect, but I hope it gives you a place to start.

I hope this helps, and best of luck!

1 Like

unfortunatly I am trying to create a script for a looping system around a loop that goes upsidedown

Unfortunately, we cannot help you make a whole system.

At most I can give advice on this aspect of the looping system which is aligning the character to the surface normal like in a loop motion, this is a whole problem in itself.

Video:

image

Possible Orientation method 1:

Now for the movement you need to somehow create a character controller that

  1. Disables gravity
  2. Creates a force/movement to stick you onto the loop (get Raycast normal in a lot of directions?)
  3. Create the camera change which goes alongside with the control scheme, never played a sonic game recently so I cannot help you with the controls here.
  4. Make the movement force perpendicular to the slopes floor

For getting a direction movement vector perpendicular to the slope perhaps you can use this cross product technique:

1 Like

Tried to use egomoose but it does not work with custom character rigs