Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Better method for raycasting direction?

Asked by 3 years ago

Currently, I am working on a punching script that, when working correctly, should fire out a short ray in front of the player's left hand. I haven't been able to figure out a way to track the raycasting direction to travel straight out from the player's fist though.

Here is the ray that is created -

local rayOrigin = leftHand.Position
local rayDirection = Vector3.new(0,-1, 0)
raycastParams.FilterDescendantsInstances = {char}
raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
local raycastResult = workspace:Raycast(rayOrigin, rayDirection, raycastParams)

As you can see, right now the ray is created slightly below the player's fist which only works part of the time. If there is a way to extend the ray outwards farther whilst still maintaining the correct orientation, that would be awesome. I'm also open to other ideas for how to make this script work, any help would be most appreciated.

0
You can simply get the rayDirection by doing: (rayOrigin - rayDestination) MarkedTomato 810 — 3y
0
Thank you, this worked Ilove_COMUNISM 35 — 3y

Answer this question