Problems with multiple Raycasting per frame + Moving part with collisions by player .?

Ok, so;
I made a script that is supposed to fire a ray from the middle of a part to all surfaces in each frame and check if there is something else than the part itself. (like a type of roughly collision detection which knows the direction where the collision is coming from and how deep it reaches)

The script:
local function POS_UPADTE()
	if mouse.Target then
		count = count + 1
		part.CFrame = mouse.Hit
		direction = {
			Vector3.new(0,part.Size.Y/2,0);
			Vector3.new(-part.Size.X/2,0,0);
			Vector3.new(part.Size.X/2,0,0);
			Vector3.new(0,0,-part.Size.Z/2);
			Vector3.new(0,0,part.Size.Z/2);
			Vector3.new(0,-part.Size.Y/2,0)
		} 
		for _, dir in ipairs(direction) do
			local result = workspace:Raycast(part.CFrame.p,dir, param)
			if result then
				print(dir)
			end
		end
	end
end

local function BUTTON_ONE(actionName, inputState, inputObject)
	if icon == true then
		if inputState == Enum.UserInputState.Begin and filter == false then
			filter = true
			mouse.Icon = "rbxassetid://6188843788"
			mouse.TargetFilter = part
			param = RaycastParams.new()
			param.FilterDescendantsInstances = {part}
			param.FilterType = Enum.RaycastFilterType.Blacklist
			RS:BindToRenderStep("Position_Update",1,POS_UPADTE)
         -- some more script but i think it doesn't matters

this script is btw an attempt to solve my other problem, read it to understand a bit more >click<

the issue with that is, that it’s like not return any result, only on the -Y ray sometimes it works too at other things but it’s hard to explain with words so here the videos:

I hope you somehow know the root of this issue.
Or know an alternate solution to the problem why I wrote this script >click< ^^

If you need more information, feel free to ask

3 Likes

Hmm, if you want to drag the part around I believe you can look at how these classic build tools are able to drag the part from how I remember it perhaps look there.

Ok, after a long time of doing some other stuff, I decided to return to this project problem.

Well, I looked into the old tools and it turns out, that it uses a Roblox Build-In function/tool called
“Dragger”.
With this I managed it to get it working without cutting throut surfaces:

The script:
local function POS_UPADTE()
	if mousePart then
		dragger:MouseMove(mouse.UnitRay)
	end
end

local function BUTTON_ONE(actionName, inputState, inputObject)
	if icon == true then
		if inputState == Enum.UserInputState.Begin and toggle == false then
			toggle = true
			mouse.Icon = "rbxassetid://6188843788"
			local PointOnTaget = mousePart.CFrame:toObjectSpace(mouse.Hit).p
			dragger:MouseDown(mousePart,PointOnTaget,{mousePart})
			RS:BindToRenderStep("Position_Update",1,POS_UPADTE)
		elseif inputState == Enum.UserInputState.End then
			mouse.Icon = "rbxassetid://6188843710"
			toggle = false
			RS:UnbindFromRenderStep("Position_Update")
			dragger:MouseUp()
		end
	end
end
         -- some more script but i think it doesn't matters

So far, so good…but now the con:
Like you maybe notice, it looks like Dragger is using a grid and because of this, it isn’t as smooth as before. Which isn’t what I want…
So I gonna need to dig deeper in the material and look at how the Dragger is done and use this information to build my own version of it.

1 Like

I made a new topic for this question again…