#Help with a roblox Tower Defense Game

1 messages · Page 1 of 1 (latest)

limpid rover
#

I recently switched from using humanoid:MoveTo() in my scripts to tweenService for moving enemies down a path in a tower defense game. This works fine and the enemies move through the waypoints in the path but with one issue.

#
local distance = (mobToSpawn.HumanoidRootPart.Position - waypoints[i].Position).Magnitude
local speed = distance / humanoid.WalkSpeed

local positionTween = tweenService:Create(mobToSpawn.HumanoidRootPart, TweenInfo.new(speed, Enum.EasingStyle.Linear), {Position = waypoints[i].Position})

positionTween:Play()
positionTween.Completed:Wait()
#

I tween the position of the HumanoidRootPart directly to the waypoint, which causes the enemies to float above the path

harsh solar
#

yo

#

@limpid rover

limpid rover
#

Yes

harsh solar
#

try use position like this

#
local distance = (mobToSpawn.HumanoidRootPart.Position - waypoints[i].Position).Magnitude
local speed = distance / humanoid.WalkSpeed

local cframe = CFrame.new(waypoints[i].Position)
local positionTween = tweenService:Create(mobToSpawn.HumanoidRootPart, TweenInfo.new(speed, Enum.EasingStyle.Linear), {CFrame = cframe})

positionTween:Play()
positionTween.Completed:Wait()
limpid rover
#

I changed that, but the problem is the enemies floating like this

#

I think its because the waypoint is above the path, but if i move the waypoint down other enemies with different sizes will stop working

harsh solar
#

uh

#

mhmmmm

limpid rover
#

I've tried using alignPosition but its too confusing for me

neat joltBOT
#

studio** You are now Level 2! **studio

harsh solar
#

add

#

offset

#

based on size

limpid rover
#

size of the humanoidRootPart

#

I could try that

harsh solar
#
local distance = (mobToSpawn.HumanoidRootPart.Position - waypoints[i].Position).Magnitude
local speed = distance / humanoid.WalkSpeed

local yOffset = mobToSpawn.HumanoidRootPart.Size.Y / 2
local cframe = CFrame.new(waypoints[i].Position + Vector3.new(0, yOffset, 0))
local positionTween = tweenService:Create(mobToSpawn.HumanoidRootPart, TweenInfo.new(speed, Enum.EasingStyle.Linear), {CFrame = cframe})

positionTween:Play()
positionTween.Completed:Wait()
#

yOffset

#

not any other offset

tight glade
#

CFrame:Lerp(math.clamp( ... ), 0, 1)

harsh solar
tight glade
#

load animation separately

harsh solar
#

idk what he talk about, but he a sure cool guy

harsh solar
#

xDDD

#

it looks funny now

limpid rover
#

yea

harsh solar
#

find a good offset

limpid rover
#

ik

tight glade
pure tangle
harsh solar
#

math people trying to overcomplicate things always:

limpid rover
#

I think Yoffest works

harsh solar
#

kool

limpid rover
#

lemme check with other enemies rq

harsh solar
#

make offset different for enemies sizes I guess

#

bros writing a math formula now

#

I bet

pure tangle
#

Fr

#

i was tinking about that

harsh solar
#

bros Eistein

pure tangle
#

he writing essay

harsh solar
#

he write a new math love story

#

dont worry

#

bro's doing all his math homework right now in this forum 100%

pure tangle
#

and came like you know what is 2 plus 2

#

ofc i know man its 45

tight glade
pure tangle
#

Yes

harsh solar
#

bro wrote allat

#

for nothing

limpid rover
#

it works instead of doing math i just move the humanoid root part down

#

thx

pure tangle
#

he writing Newton's Gravity Formula

harsh solar
pure tangle
#

Bro is angry

harsh solar
#

I think we gonna see a new reform in math history right now

pure tangle
#

Yes

#

Bro wtf are you writing like

#

12000 pages math formula?

harsh solar
#

wtf this dude writing

#

@limpid rover can u close this

#

forum?

#

think guy is writing his life plans here

limpid rover
#

yep

tight glade
#

no

#

local zombieSpeed = 10 -- studs/sec
local zombieSize = Vector3.new(2, 4, 2) -- :GetExtentedSize()
local zombieStartPosition = Vector3.new(0, 2, 0) -- :GetPivot().Position

local point = Vector3.new(10, 0, 10) -- point to zombie need to go(let him on the ground to point)

local toGo = point + Vector3.new(0, zombieSize.Y/2, 0)

game["Run Service"].Heartbeat:Connect(function(dt)
timer += dt
zombieStartPosition:Lerp(toGo, math.clamp ( zombieSpeed * timer), 0, 1 )
end)

harsh solar
#

bro said no 💀

harsh solar
#

@pure tangle we got scammed....

pure tangle
#

yep

harsh solar
#

bro even sent no logic code

tight glade
#

stop i think

pure tangle
#

NOW GIMME MY 5+5 min

harsh solar
pure tangle
#

no 32

tight glade
#

but there's still a lot to do if you're doing tower defense

harsh solar
#

@pure tangle I think this guy is a monkey

#

but not sure yet

pure tangle