#Alternative to touched event that isn't raycast

1 messages · Page 1 of 1 (latest)

thorn edge
#

Say I have a Player and I wanted them to run around in a board and do something when they touch a tile inside the board. Currently my code looks something like this

for _, BodyPart in Character:GetChildren()
  if BodyPart:IsA("BasePart") and BodyPart.Name ~= "HumanoidRootPart" then
    BodyPart.Touched:Connect(function(OtherPart)
      ...
    end)
  end
end

This works perfectly but issue is this stops working when I play an animation on my character, I would assume this has to do with Touched event being physics based. I tried other alternative such as Raycast which solved my issue with the animation at the cost of it being inaccurate.

It's even worse for other alternatives such as Worldroot:GetPartsInPart() and Worldroot:GetPartsInBoundBox() as they're both inaccurate and stops working when run animation is played.

This script is placed inside of a local script, I am aware this is a bad practice but this isn't a concern as of right now.

#

btw that code i wrote is just a pseduocode, the actual issue is hitbox being not accurate and this is espacially a problem because my character will ragdoll, rotating and get flinged all over the board

woven sphinxBOT
#

studio** You are now Level 10! **studio

thorn edge
#

also ping me if you're replying

brazen wind
#

getpartsinpart

#

@thorn edge

#

it returns an array so you can use it in a for loop

#

to check for anything touching the part

thorn edge
#

Both inaccurate and stops working when I play animations on character

brazen wind
#

er

#

i never used worldroot getpartsinpart

#

always workspace

#

i doubt it'll be any different tho

#

wdym by raycast being inaccurate btw

#

like it not triggering sometimes?

thorn edge
brazen wind
#

ah ic

thorn edge
#

Worldroot can either be workspace or world model

#

In my case it's workspace

brazen wind
#

alr

thorn edge
# brazen wind wdym by raycast being inaccurate btw

Basically because raycast shoots lines downwards from the center of a part to detect an object, when the player touches a tile using their far side of limb, it doesn't register cuz technically it's not touching yet.

Comparison between touched and raycast

#

I don't know why GetPartsInPart and GetPartsInBoundBox also does this

#

Apparently they're just raycast too

#

Don't know if I should use shapecast knowing it's performance heavy and I assume it only works in one direction when my game sometimes rotate the board to the side or make it upside down

timber geode
#

or you can use GetPartsInPart in part that connected to your leg and have bigger hitbox

thorn edge