What do you want to achieve? I am trying to create a spinning ability where when you spin around, it plays a spinning animation and you can do some cool tricks, similar to Super Mario Odyssey:
What is the issue? I’m not quite sure how to go about doing this. I think that would has something to do with movement vectors and dot products though.
What solutions have you tried so far? I’ve tried looking for solutions on the Roblox developer forum but there wasn’t any. I even looked on other non-Roblox forums, but I am not sure how to recreate them in Roblox.
For the Mario Odyssey example shown in the video, it doesn’t appear to change movement compared to normally jumping/walking around.
I assume it’s as simple as knowing when the user is moving around in a circle quickly, and then playing an animation. That first part can be done by using the Thumbstick/input, but a more multi-input-friendly way would be to base it on movement. I wouldn’t base this detection based off of the camera either, unless the game is in first-person, but I digress.
I can’t figure out how to use the resources you provided for my project. My movement system does not use regular characters but instead uses a main part that moves around for the sake of customization. Also, I don’t really understand how the code in “Detect If Player Has Spun Around Fully in a Circle” works. Can you provide any other resources or explain a possible way to recreate the ability?
I decided to try making this and here’s the result:
Discussion: What’s Wrong with this Solution?
This uses the Thumbstick input to determine when to do a “spin move”. A better implementation would work for all InputTypes. I already stated that in the other post, so apologies for not solving that issue. I’m not entirely sure how to make this work for all InputTypes. If I have time and find a solution, I’ll be sure to reply with an update.
local UserInputService = game:GetService("UserInputService")
local spinAnimation = script.Parent:WaitForChild("Humanoid"):LoadAnimation(script.spinAnimation)
local timerStarted = false
local startTime
local timeLimitForSpinMove = 2
local totalLeewayForDegreeChecking = 5
local degCheck1 = false
local degCheck2 = false
local degCheck3 = false
local degCheck4 = false
UserInputService.InputChanged:Connect(function(input)
if input.KeyCode == Enum.KeyCode.Thumbstick1 then
-- get degree of thumbstick rotation:
local rotation_inDeg = math.deg(math.atan2(input.Position.Y,input.Position.X))
local simplifiedDeg = math.round(rotation_inDeg)
--print(simplifiedDeg)
if degCheck1 == false and simplifiedDeg >= 45 - totalLeewayForDegreeChecking/2 and simplifiedDeg <= 45 + totalLeewayForDegreeChecking/2 then
degCheck1 = true
elseif degCheck2 == false and simplifiedDeg >= 135 - totalLeewayForDegreeChecking/2 and simplifiedDeg <= 135 + totalLeewayForDegreeChecking/2 then
degCheck2 = true
elseif degCheck3 == false and simplifiedDeg >= -135 - totalLeewayForDegreeChecking/2 and simplifiedDeg <= -135 + totalLeewayForDegreeChecking/2 then
degCheck3 = true
elseif degCheck4 == false and simplifiedDeg >= -45 - totalLeewayForDegreeChecking/2 and simplifiedDeg <= -45 + totalLeewayForDegreeChecking/2 then
degCheck4 = true
end
if timerStarted == false then
timerStarted = true
startTime = os.time()
else
local timeSinceTimeStarted = os.time() - startTime
if timeSinceTimeStarted > timeLimitForSpinMove then
timerStarted = false
else
local allDegreesMetToCountARotation = degCheck1 and degCheck2 and degCheck3 and degCheck4
if allDegreesMetToCountARotation then
degCheck1 = false
degCheck2 = false
degCheck3 = false
degCheck4 = false
print("full rotation in amount of time!")
spinAnimation:Play()
end
timerStarted = false
end
end
end
task.wait()
end)
I got something working using your game file. It works for PC, Xbox, and Mobile.
I’ll try to implement it into my game, but for now, it works fine! Thx for helping me create this spin ability. Also, if anyone wants the file for some reason, here it is. [WARNING MY MODIFIED CODE KIND OF SUCKS]