Checking if player is "half" inside an object (trying to replicate Portal's portal effect)

What do you want to achieve? Keep it simple and clear!
Trying to check if a player is half inside of another part.
→ Something like here

I’m sorry if im missing any information, if so please ask me for more details.

I think you could just use the .Touched event

You could compare positions PlayerPosition == PartPosition but that is unreliable because of the fact we use floating points so any small change will make it fail.
Considering you are making a portal (because of the video), one of the solutions can be to check if the player has passed through the middle using dot product, something like: (Warning, this is a pseudo code)

local LastDotProduct = 0
function HasPassedThrough(DotProduct)\
   if DotProduct <= 0 and LastDotProduct >0 then --Player is behind and was in front in the previous frame
      return true
   end
   LastDotProduct = DotProduct
   return false
end

and, still considering you are making a portal, just store the offset between the player and the part and then apply it after teleportation.

Note: I am giving a solution based on the context of the video as you haven’t stated what you’re doing.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.