#how do i make these collisions not happen

1 messages · Page 1 of 1 (latest)

finite ingot
#

i have a system that gets buildings and puts them in random positions but what what if the buildings are colliding against eachover?

steep plover
finite ingot
#

ty

finite ingot
steep plover
#

hmm, your case would have to work a bit different

#

you'd want to generate a part/the hitbox of the building you're GOING to build, and then check if any buildings already exist inside it (using GetPartsInPart)

finite ingot
#

im using findfirst ancestors but it says it expects a string but got a table

#

oh nvm

#

got it

#

i need the name of the part im using

#

it isnt working right now

#

i dont know why

steep plover
#

any errors, or what is it doing rn?

finite ingot
#

ill send the script and a screenshot

#

output is clear btw

steep plover
#

show your new code?

finite ingot
#

distancing is the white box around the house

#

ive never used getparts in part and im not familiar with find first ancestor

steep plover
#

dw, shouldnt be hard to fix

#

FindFirstAncestor is just as it says, it goes upwards through the parents until it finds one with a matching name

#

having a look now

#

ahhh okay

#

so, it depends on your setup

finite ingot
#

all the buildings are in a folder

#

if it goes through the parents and not the children

#

then it wont find the other models its touching

steep plover
#

yup, you got it

#

so, maybe use something else

finite ingot
#

so i use getdescentants?

#

on the folder

steep plover
#

either the building name with FindFirstAncestor, or just do if part.Parent:FindFirstChild("Distancing")

#

latter seems cleaner

finite ingot
#

latter.?

steep plover
#

the 2nd option of what i just said

finite ingot
#

oh ok

#

i got script timeout using the second option

woven smeltBOT
#

studio** You are now Level 3! **studio

finite ingot
#

any solutions to that?

#

i think ive had it once

#

before but i dont know anything about it

steep plover
#

hm

#

you shouldnt have

#

one min

finite ingot
#

the part is inside the model

#

im confused

#

because when you do part.parent

#

its essentially just searching its self

steep plover
#

ahhhh true, my bad

#

youll need to exclude it

#

you can do that with OverlapParams

#

can you paste your code here

#

instead of screenshotting

#

ill edit if you like, should work

finite ingot
#

ok

#

wait

#

how do i copy and paste it like how you did in the other thread

#

lemme show a example

robust nymph
#

why ping me

steep plover
finite ingot
#

mb

#

my fault

steep plover
#

anyway dw

#
local Map = workspace:WaitForChild("Map")
local Buildings = Map:WaitForChild("Buildings")



local function randomizeposition(Building)
    local X = math.random(-400,400)
    local Z = math.random(-400,400)

    local RandomOrientation = math.random(1,360)

    Building:SetPrimaryPartCFrame(CFrame.new(X,1, Z) * CFrame.Angles(0, math.rad(RandomOrientation), 0)) -- move 20 studs in the y-axis from the origin and rotate 45 degrees in the y-axis

    local params = OverlapParams.new()
    params.FilterType = Enum.FilterType.Blacklist
    params.FilterDescendantInstances = {Building.Distancing}

    local parts = workspace:GetPartsInPart(Building.Distancing,params)

    local CollisionFound = false
    for _, part in parts do
        if    part.Parent:FindFirstChild("Distancing") then

            print("found collision")
            CollisionFound = true

            break
        end
    end

    if CollisionFound then
        randomizeposition(Building)
        print("Building Had Collision With Other Building.Relocating Building")
    end
end
for i,Model in pairs(Buildings:GetChildren()) do
randomizeposition(Model)

end
#

added 'params' and adjusted the 'local parts = ' segment

finite ingot
#

there

steep plover
#

nice

#

but also dont worry i edited already

#

above

finite ingot
#

oh k

steep plover
#

basically just added a blacklist to it

#

but, im not sure if thats the main problem if you were getting a script timeout

#

unless there's just not any space for the new building, which would cause that!

#

just increase the x and z

finite ingot
#

ok

#

oh yeah your right

steep plover
#

wooooo

#

works now?

finite ingot
#

the capacity of it is 400

steep plover
#

yee

finite ingot
#

but the distancing is 100

#

i added 10 testing houses

#

for the scripting

#

ill do that now

#

uhh

#

still got script timeout

#

i dont know how

#

found collision (x1622)

steep plover
#

it's always colliding?

#

seems odd

#

lower the number of houses

finite ingot
#

ok

#

it keeps timing out a taround 1600 to 1700 collisions

#

then doesnt work

#

OH

#

MY BAD

#

ive got it now

steep plover
#

what was it lol

finite ingot
#

i didnt copy and paste the script u did

#

i didnt see it

#

i was afk for a few minutes

#

nvm that was a lie

#

i responded 1 minute after

#

im just slow

#

isnt blacklist deprecated

#

yeah they are

#

they were deprecated

woven smeltBOT
#

studio** You are now Level 4! **studio

finite ingot
#

until recently they were deleted

#

they were replaced with exclude/include

#

im gonna try that instead

steep plover
#

oh yes, mb

#

should function the same tbh

finite ingot
#

fixed it

steep plover
#

goated

#

gj

finite ingot
#

if u dont know blacklist is now RaycastFilterType.Exclude

#

i think

steep plover
#

yesss indeed

#

i thought it was the other way around with which are deprecated

finite ingot
#

ohh ok

#

this is done now

#

i guess i got the complicated stuff down