shocking title i know right, well im trying to recreate the grabpack from poppy playtime and my original hand placement was by using target.hit, however im thinking of switching to raycasting instead because i want to achieve this (in the video) where the hands travel a small distance between returning immediately. I just want to know how i would best achieve my desired results?
#Hands
1 messages · Page 1 of 1 (latest)
Well even if you would use raycasting the hit location would still be infinitely far away if that is the issue.
Maybe a fix for this could be creating a part at the max distance?
i thought of that, but can you not set a distance for the raycast?
Well I never heard of that. have you tried researching for that?
local Workspace = game:GetService("Workspace")
local function castRay()
-- The origin point of the ray
local originPosition = Vector3.new(0, 50, 0)
-- The direction the ray is cast in
local direction = -Vector3.yAxis
-- The maximum distance of the ray
local distance = 50
-- Cast the ray and create a visualization of it
local raycastResult = Workspace:Raycast(originPosition, direction * distance)
if raycastResult then
-- Print all properties of the RaycastResult if it exists
print(`Ray intersected with: {raycastResult.Instance:GetFullName()}`)
print(`Intersection position: {raycastResult.Position}`)
print(`Distance between ray origin and result: {raycastResult.Distance}`)
print(`The normal vector of the intersected face: {raycastResult.Normal}`)
print(`Material hit: {raycastResult.Material.Name}`)
else
print("Nothing was hit")
end
end
-- Continually cast a ray every 2 seconds
while true do
castRay()
task.wait(2)
end
``` here is documented code
im not sure if it helps my case but i used this example to give distance to raycasts in past projects
why do you make reference to the workspace? and why do you use comments so often? This code is kind of suspicious if you feel me.
i see
so does this ray just end after 50 studs? Because i would think that this would still travel on infinitely.
Did some research and i think this might be it.
Im not really good at math so idk if it will work flawlessly but its worth a try i think
👍
you can choose distance of ray, its in the direction paramter
would i be able to get the cframe of the end distance if the ray doesnt detect anything
I take inspiration from this game, i noticed that the guns follow the hand until it returns, however the guns are both a singular meshpart with bones and joints. how would i do this?
you can define a max length, if it doesnt hit anything then just use that distance
like if ray.result = nil
when you ray cast , the direction you sets magnitude depends on how far the ray goes. so Vector3.new(0,500,0) would make a ray cast 500 studs up. to check if it hit anything it's either the ray cast returns nothing or result.Instance is nil, i forgot, you can also use result.Position i think to see where it hits
i can elaborate more when i'm on pc later, it's kind of limiting to do research on my phone
Im currently trying lerp and spring, the result i wanted wasnt nice enough and im using a viewmodel so the position changes alot. Lerp is a bit difficult for me since im not sure how i can do it perfectly i guess
alright
@narrow hollow could you ping me when your on pc? I have this problem and im not sure hwo to fix it
whats the issue?
I used the cframe of the hand instead of the start frame so it looked weird, but my problem is I'm not sure how I can make the guns look at the hands, I use joints because it's a meshpsrt
i don't understand
im not sure if its a joint problem or something but yeah