#💬 eeeeee1234567890123456789ʹs Feedback

1 messages · Page 1 of 1 (latest)

sonic beaconBOT
untold sun
#

why didn't u show it running in real time so we could see the actors

scarlet tide
untold sun
#

thats what actors are for tho

scarlet tide
untold sun
#

very cool good job :)

#

are you accounting for overlaps/already filled tiles?

scarlet tide
#

then i do this 💀

untold sun
#

u want pro tip

scarlet tide
untold sun
#

when you are comparing distances and you don't actually care about the distance itself you only care about it's relative value you can use square magnitude
which looks like this:

local v = Vector2Position - Vector2.new(At.X, At.Z)
local sqareMag = v:Dot(v)
local isInCircle = squareMag <= halfRenderDistance^2
#

its wayy more efficient because it skips the square root function that Magnitude uses

scarlet tide
#

whoa math

untold sun
#

i can explain the math if u want too

#

but it boils down to v:Dot(v) is equivalent to the inside part of the distance function

scarlet tide
#

i wont get a single thing

untold sun
#

you underestimate yourself

scarlet tide
#

code died 💀

untold sun
#

you know how distance =√((x2 – x1)² + (y2 – y1)²)

untold sun
#

v:Dot(v) = v.X^2 + v.Y^2 and v is already the difference between the two vectors
(x2 – x1)² + (y2 – y1)²

scarlet tide
untold sun
#

so it just does the inner part of it

#

can i see what you originally had on the full IsInCircle line

#

you cut off a part of it

scarlet tide
untold sun
#

ah i didn't see that part

#

yeah good job

#

faster

scarlet tide
#

also the memory increases a lot when generating (would eventually stack up to a gigabyte) should i eventually with time remove old chunks?

untold sun
scarlet tide
#

but since i cant initialize it as nil

#

i put it in a table

#

later on i find that model and put the model to that table

scarlet tide
#

that findfirstchild isnt the best but it is the easiest for me currently

untold sun
#

storing models is pretty space efficient actually so you should be fine there I think it's fine just probably because you're creating so many parts at once

#

yeah converting to a string and using findfirstchild could probably be improved upon

#

also find a way to not use pairs

scarlet tide
scarlet tide
untold sun
#

yes

#

significantly

scarlet tide
#

ipairs and pairs?

untold sun
#

yes

#

ipairs much faster than pairs

#

and when you're doing it a lot it makes a difference

scarlet tide
#

also my current way of checking if a given space is already occupied is just indexing it, would using table.find be better

#

or is there any alternatives

untold sun
#

indexing is fine

#

its the fastest

scarlet tide
#

well i cant index it if i dont have the index 💀

untold sun
#

what are you using for an index

scarlet tide
#

the snapped position of the chunk

untold sun
#

thats fine then

scarlet tide
#

converted to vector3

untold sun
#

you can just get the close by grid snapped points

#

and use them as indexes

#

which should be pretty fast to get

untold sun
#

like get nearby vector2 values and check if they're occupied

scarlet tide
#

is that not what im doing?

untold sun
#

you're going through already generated chunks tho? maybe im confused

scarlet tide