I want to recreate this effect from tower defence simulator to make my towers bounce / sway.
I have got the delta, but i do not have any clue on how I would make it move in that way.
I found this post Attempting to do a “sway” effect however, it is very complicated for my tiny brain. I am very good at other things, just not so good with springs. I have tried many ways, but they don’t work. I am using Quenty’s spring module
2 Likes
Synarx
(syn)
June 24, 2023, 10:59pm
#2
My humble sir, I’m glad your using Quentys Spring module. I was just about to post it.
No need. Straight to the example!
local DeltaSpring = Spring.new(Vector3.zero)
DeltaSpring.d = 0.8
DeltaSpring.s = 12
-- loop:
DeltaSpring.t = Last - CurrentPosition
Last = CurrentPositon
local Sway = CFrame.Angles(DeltaSpring.p.Z, 0, DeltaSpring.p.X)
Edit to heart content.
2 Likes
I am not seeing any movement / sway?
DeltaSpring.t = Previous - TowerModel.PrimaryPart.CFrame.Position
local Sway = CFrame.Angles(DeltaSpring.p.Z, 0, DeltaSpring.p.X)
TowerModel.PrimaryPart.CFrame = CFrame.new(RayCast.Position + Vector3.new(0, TowerDataBase.Placing[1].YOffset, 0)) * CFrame.Angles(0, math.rad(TowerDataBase.Placing[1].Rotation), 0) * Sway
Synarx
(syn)
June 25, 2023, 10:07am
#5
Weird, could you send your full code?
1 Like
RayCast = MouseRayCast({TowerModel, workspace.Enemies, workspace.Towers, PlayerModels, workspace.Obstacles})
if Previous then
DeltaSpring.t = Previous - TowerModel.PrimaryPart.CFrame.Position
local Sway = CFrame.Angles(DeltaSpring.p.Z, 0, DeltaSpring.p.X)
TowerModel.PrimaryPart.CFrame = CFrame.new(RayCast.Position + Vector3.new(0, TowerDataBase.Placing[1].YOffset, 0)) * CFrame.Angles(0, math.rad(TowerDataBase.Placing[1].Rotation), 0) * Sway
end
Range.CFrame = CFrame.new(Vector3.new(TowerModel.PrimaryPart.Position.X, RangeY, TowerModel.PrimaryPart.Position.Z)) * CFrame.Angles(0, 0, math.rad(90))
Previous = TowerModel.PrimaryPart.CFrame.Position
RayCheck(TowerInfoDataBase[TowerModel.Name].Range)