Deleted post deleted post

deleted post deleted post deleted post

10 Likes

Oh wow, the revamped version looks a lot shorter and cleaner than the original one. Thanks for sharing this resource! :+1:

1 Like

Have fun with that!

Totally not gonna one-up your one-up… >:3

Maybe you should remove the jumping print since it lags the output.

1 Like

Oh whoops… forgot I added those…
I’d fix it but uhh…
image
Roblox is being super silly and won’t let me launch studio so I’ll do it later. For now just remove the two prints manually.

Roblox seems to be behaving now; fixed!

This is really good to see. The Animate script is (imo) a huge impediment to developer customization. It’s a pain to work with (and in most cases, around) and making simple changes to animation behavior is rarely as natural and clean as it should be. It’s really great to that old code cleaned up (even if it’s an earlier iteration - the current Animate script is loads more horrendous).

Awesome to see!

1 Like

Oh definitely. Perhaps I should move onto cleaning that up. I’d probably have to redo Roblox’s provided animations since they’re pretty awful. (Have you noticed how the walking animation makes the left arm jut out a ton?)

Though honestly, maybe I should just try to add animation support to this instead of trying to modify the modern script, it doesn’t really seem to be missing anything other than emotes, which I don’t believe is all that important, and tools, which I’ll look into supporting if it doesn’t turn the code into spaghetti.

I thought about redoing the horrendous current Animate script… and I determined it was best to just throw it out and create a complicated Module System for it.

It would be cool if you changed the lighting mode to compatability.

Very cool, just for the place to give off a more og feel as @RoninQV said above, change the lighting and decrease the gravity and jump power to get that og jump

Alright, I did it last night, and touched it up today:

It’s a bit more complicated… cause I like that I guess. But I made sure everything was well-commented, efficient, and organized.

The best viewing experience will be if you open the script in studio and right click “Collapse all Folds”

--=========================================================================================>
-- NAME: 2012 Animate Revamped
-- ORIGINAL AUTHOR: carrot (@KyjiPaws)
-- CURRENT AUTHOR: Sato (@IISato)
--==========================================================================================--
--!strict
--==========================================================================================--

-- DEFINE VARIABLES:

-- Service and Instance Variables:
local RunService : RunService, Humanoid : Humanoid, HumanoidRootPart: BasePart
-- Table Variables:
local TorsoData : any, PoseData : any, EventData: any

--==========================================================================================--
--[ UTILITY FUNCTIONS: ]

-- Function which returns whether the Character is moving based on MoveDirection magnitude:
local function IsMoving() : boolean
	
	--=====================================================================--
	
	-- Get Velocity of the HumanoidRootPart (Character Velocity)
	local Velocity = math.floor(HumanoidRootPart.AssemblyLinearVelocity.Magnitude)
	
	-- If MoveDirection Mag is greater than .99 (Meaning Player is trying to move)
	-- AND the actual HumanoidRootPart Velocity (Actual Movement) is greater than 0
	-- Will stop the Run Animation when walking into a wall. (New Feature..)
	return Humanoid.MoveDirection.Magnitude > .99 and Velocity > 0
	
	--=====================================================================--
	
end

-- Function which Changes the Pose from Standing to Running based on whether the Character is moving every frame:
local function RunningUpdate()
	if PoseData.CurrentPose == "Standing" or PoseData.CurrentPose == "Running" then 
		PoseData.CurrentPose = if IsMoving() then "Running" else "Standing"	
	end
end

-- Function which will play the Animation for whichever Pose is active
local function PlayAnimations()

	--=====================================================================--

	-- Assign the CurrentPose value to a local Variable for looks.
	local CurrentPose : string = PoseData.CurrentPose :: string

	--=====================================================================--

	if CurrentPose == "Dead" then

		-- Clear the Event Connections:
		for Index, Event in pairs(EventData) do Event:Disconnect() end

		-- Destroy the Script:
		script:Destroy() 

	end

	if CurrentPose == "Jumping" or CurrentPose == "Freefall" then

		TorsoData['Left Shoulder'].MaxVelocity = 0.5
		TorsoData['Right Shoulder'].MaxVelocity = 0.5
		TorsoData['Left Shoulder']:SetDesiredAngle(-math.pi)
		TorsoData['Right Shoulder']:SetDesiredAngle(math.pi)
		TorsoData['Left Hip']:SetDesiredAngle(0)
		TorsoData['Right Hip']:SetDesiredAngle(0)

	end

	if CurrentPose == "Seated" then

		TorsoData['Left Shoulder'].MaxVelocity = 0.15
		TorsoData['Right Shoulder'].MaxVelocity = 0.15
		TorsoData['Left Shoulder']:SetDesiredAngle(-math.pi / 2)
		TorsoData['Right Shoulder']:SetDesiredAngle(math.pi / 2)
		TorsoData['Left Hip']:SetDesiredAngle(-math.pi / 2)
		TorsoData['Right Hip']:SetDesiredAngle(math.pi / 2)

	end

	if CurrentPose == "Running" or CurrentPose == "Swimming" then

		TorsoData['Left Shoulder'].MaxVelocity = 0.15
		TorsoData['Right Shoulder'].MaxVelocity = 0.15

		local DesiredAngle = 1 * math.sin(os.clock() * 9)

		TorsoData['Left Shoulder']:SetDesiredAngle(DesiredAngle - 0)
		TorsoData['Right Shoulder']:SetDesiredAngle(DesiredAngle + 0)
		TorsoData['Left Hip']:SetDesiredAngle(-DesiredAngle)
		TorsoData['Right Hip']:SetDesiredAngle(-DesiredAngle)

	end

	if CurrentPose == "Climbing" then

		if IsMoving() then

			TorsoData['Left Shoulder'].MaxVelocity = 0.5
			TorsoData['Right Shoulder'].MaxVelocity = 0.5
			TorsoData['Left Hip'].MaxVelocity = 0.1
			TorsoData['Right Hip'].MaxVelocity = 0.1

		else

			TorsoData['Left Shoulder'].MaxVelocity = 0
			TorsoData['Right Shoulder'].MaxVelocity = 0
			TorsoData['Left Hip'].MaxVelocity = 0
			TorsoData['Right Hip'].MaxVelocity = 0
		end

		local DesiredAngle = 1 * math.sin(os.clock() * 9)

		TorsoData['Left Shoulder']:SetDesiredAngle(DesiredAngle - math.pi)
		TorsoData['Right Shoulder']:SetDesiredAngle(DesiredAngle + math.pi)
		TorsoData['Left Hip']:SetDesiredAngle(-DesiredAngle)
		TorsoData['Right Hip']:SetDesiredAngle(-DesiredAngle)

	end

	if CurrentPose == "Standing" then

		TorsoData['Left Shoulder']:SetDesiredAngle(0)
		TorsoData['Right Shoulder']:SetDesiredAngle(0)
		TorsoData['Left Hip']:SetDesiredAngle(0)
		TorsoData['Right Hip']:SetDesiredAngle(0)

	end

	--=====================================================================--

end

--==========================================================================================--
--[ SETUP FUNCTIONS: ]

-- Function which will set and declare any global variables, and setup Data:
local function SetVariables()

	--=====================================================================--

	-- Character Model Instance
	local Character: Model = script:FindFirstAncestorOfClass("Model") :: Model

	-- Character Torso Instance
	local Torso : BasePart = Character:WaitForChild("Torso") :: BasePart

	--=====================================================================--

	-- Roblox RunService
	RunService = game:GetService("RunService") :: RunService

	-- Character Humanoid Instance
	Humanoid = Character:WaitForChild("Humanoid") :: Humanoid
	
	-- Character HumanoidRootPart Instance
	HumanoidRootPart = Character:WaitForChild("HumanoidRootPart") :: BasePart
	
	-- PoseData Dictionary, containing the humanoid states that are allowed as poses, and the currentpose.
	PoseData = {
		-- Allowed Humanoid States as Poses Array:
		Poses = {"Running", "Climbing", "Jumping", "Freefall", "Seated", "Dead", "Swimming"},
		-- CurrentPose the Character is in
		CurrentPose = "Standing"
	}

	-- Empty TorsoData Dictionary to be filled with Instances
	TorsoData = {
		["Left Shoulder"] = "", ["Right Shoulder"] = "", ["Left Hip"] = "", ["Right Hip"] = "", ["Neck"] = ""
	}
	
	-- Declare EventData as an empty table
	EventData = {}
	
	--=====================================================================--

	-- Fill the TorsoData Dict by waiting for each Index in the Torso Instance and adding it to the Dictionary.
	for Index, TorsoChild in TorsoData do TorsoData[Index] = Torso:WaitForChild(Index) end

	--=====================================================================--

end

-- Function which will Connect all the needed events in the script:
local function ConnectEvents()
	
	--=====================================================================--

	EventData["State"] = Humanoid.StateChanged:Connect(function(OldEnmuState, NewEnumState)
		
		--===============================================================--
		-- [ Format Variables: ]

		-- Initiate new Variables which will be the formatted string version of the Enums:
		local NewState: string, OldState: string = tostring(NewEnumState), tostring(OldEnmuState)
		
		-- Replacement Pattern (so that I can one line the variable sets):
		local Pattern = "Enum.HumanoidStateType."
		
		-- Format the String Enums to not have the Enum parts:
		NewState, OldState = string.gsub(NewState, Pattern, ""), string.gsub(OldState, Pattern, "")	
	
		--===============================================================--
		
		-- If Pose is not in the PoseData poses table, return
		if not table.find(PoseData.Poses, NewState) then return end
		
		--===============================================================--
		-- [ Set the changed Pose: ]
		
		if NewState == "Running" then 
			PoseData.CurrentPose = if IsMoving() then "Running" else "Standing"	
		else
			PoseData.CurrentPose = NewState	
		end
		
		--===============================================================--
		
	end)

	EventData["Anim"] = RunService.PreAnimation:Connect(function()

		--===============================================================--
		
		-- Update the Pose if Moving:	
		RunningUpdate()

		-- Motor Animations Function:
		PlayAnimations()
		
		--===============================================================--

	end)

	--=====================================================================--

end

--==========================================================================================--
--[ MAIN SCRIPT FUNCTION: ]

-- Function which will run the Script Setup Functions:
local function Main()
	
	--=====================================================================--
	
	-- Set Script global variables:
	SetVariables()
	
	-- Connect Events:
	ConnectEvents()
	
	--=====================================================================--
	
end

--==========================================================================================--

Main() -- Start the script:

--==========================================================================================--

Some Extras:

  • Movement checker to determine whether the Character is moving to stop Animations from playing otherwise.
  • Used movement check to have Climb Animation only play when moving and climbing and to freeze when still.

Looks like a massive amount of code for something that pretty much does the same thing…
Might look into adding a check for stopping the climbing animation, but at that point I think it’d become its own thing.

Intentionally making my game look ugly just to give off a “classic” vibe is not something I intend on doing.

Be honest, this looks awful.

This on the other hand… :smiling_face_with_three_hearts:

2 Likes

I mean half the lines are comments, and I opted for the one state change event rather than individual state connections.

I’m just a little confused on why, considering the script was already like… 80 lines of code excluding comments. Just seems odd to over complicate what already works fine.

Your code is I believe 120.

Yeah, yours does work fine, it’s good. I just wanted to make it a little more advanced I guess.

My script is about 107 lines in it’s readable form (the condensed version is what i was referring to when I said 80 lines), While yours is about 265 lines.

I don’t really think nearly tripling the length of the script for like, two visible changes, is really worth it in my opinion, at least in the case of a simple little animate script that already takes less than about 10 microseconds to run.

You’re vastly over exaggerating the effect of a 100 lines of code.

1 Like

Alright, I did a load time test of the scripts:
Miniscule difference, but not worse.

Sato’s:
image
Carrot’s
image

My point was that it didn’t matter. Saving 4 microseconds on startup isn’t significant. ;w;