Hi, I am a beginner script developer. I have a question, so I am posting on the Developer Forum.
(I used a translator.)
I am a developer working on a reactor core game. In the popular game ‘B Core,’ the core moves naturally when it becomes unstable. I tried to achieve something similar using TweenService, but it wasn’t very successful.
I wanted to recreate the effect shown in the video above, so I used TweenService, but it wasn’t as natural and smooth as in the video. In the video, it looks like the core moves to random positions and moves in a natural way. If you know any methods to make parts move with a natural, unstable feeling like in the video, please help me.
math.noise() is your best friend when it comes to procedurally generated stuff. You can make a script that offsets the core from it’s initial position every frame/step.
I don’t know what example I can show because I don’t use it a lot, but there should be plenty of tutorials on it.
local TweenService = game:GetService("TweenService")
local Core = script.Parent
local OriginPosition = Vector3.new(0,0,0)
local OriginSize = Vector3.new(3,3,3)
local function RandomizeTween()
local XPosition = math.random(OriginPosition.X-1, OriginPosition.X+1)
local YPosition = math.random(OriginPosition.Y-1, OriginPosition.Y+1)
local ZPosition = math.random(OriginPosition.Z-1, OriginPosition.Z+1)
local XSize = math.random(OriginSize.X-0.5, OriginSize.X+0.5)
local YSize = math.random(OriginSize.Y-0.5, OriginSize.Y+0.5)
local ZSize = math.random(OriginSize.Z-0.5, OriginSize.Z+0.5)
local TimeTable = {0.7, 0.8, 0.9, 1, 1.1, 1.2}
local ChoosenTime = TimeTable[math.random(1, #TimeTable)]
local Info = TweenInfo.new(ChoosenTime, Enum.EasingStyle.Linear)
local PositionGoal = Vector3.new(XPosition, YPosition, ZPosition)
local SizeGoal = Vector3.new(XSize, YSize, ZSize)
return Info, PositionGoal, SizeGoal
end
while task.wait(0.5) do
local Info, PositionGoal, SizeGoal = RandomizeTween()
TweenService:Create(Core, Info, {Position = PositionGoal, Size = SizeGoal}):Play()
end