I want to do a system like ‘Door’, so when you go near to a door, the door open, i have try to understand on youtube but I don’t find great result.
Thank you!
I want to do a system like ‘Door’, so when you go near to a door, the door open, i have try to understand on youtube but I don’t find great result.
Thank you!
use Magnitude
local Mag = (Part1.Position - Part2.Position).Magnitude
if Mag <= 12 then
print("Part2 is near Part1")
end
thank you I think is that but I can test now, I’m not at my home.
I didn’t think anyone would answer me so fast, sorry!
Instead of constantly calculating the distance it would be way easier and less performance heavy to just use ZonePlus. Basically, when the player enters the zone near the door, it opens and the next room generates, this is what ive done in my own game I made that was based on Doors.
Or you can just make a hitbox part slightly bigger than the door and use the Touched event.
Magnitude check is always going to be more performant than zonePlus. It’s a O(1) operation vs a spatial query
I wouldn’t recommend the .Touched event because from my own experience I always found it really inconsistent.
If your doing it for the player
use .touched for only the hrp this has given me the best results! and use a debounce lol