Hello developers
i’m making a cooking system and with some help i got a part of the work done of the dragging system.
this is what currently i have
The next thing that i need is checking with Raycasting
the position to land the ingredients.
this is what i mean:
The red line would be the Ray, i want the ingredients to fall to the end of the ray and get on the table.
this is the code:
--//Services
local Players = game:GetService("Players")
local TweenService = game:GetService("TweenService")
--//Variables
local LocalPlayer = Players.LocalPlayer
local Mouse = LocalPlayer:GetMouse()
local Character = LocalPlayer.Character or LocalPlayer.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")
local CurrentCamera = workspace.CurrentCamera
--//Controls
local Point = nil
local Clicking = false
local tweenInfo = TweenInfo.new(0.1)
--//Initialization
if game.Loaded then
CurrentCamera.CameraType = Enum.CameraType.Scriptable
CurrentCamera.CFrame = workspace.CamaraMostrador.CFrame
end
--//Functions
Mouse.Button1Up:Connect(function()
Clicking = false
Point = nil
Mouse.TargetFilter = nil
end)
Mouse.Button1Down:Connect(function()
if Mouse.Target and not Mouse.Target.Locked and Mouse.Target:IsA("BasePart") and Mouse.Target:FindFirstChild("Value") then
Point = Mouse.Target
Mouse.TargetFilter = Point
Clicking = true
end
end)
Mouse.Move:Connect(function()
if Clicking and Point then
local TweenAnimation = TweenService:Create(Point, tweenInfo, {Position = Mouse.Hit.Position + Vector3.new(0, Point.Size.Y * 2, 0)})
TweenAnimation:Play()
--[[
Point.Position = Vector3.new(PosX,PosY,PosZ)
]]
end
end)
I make this topic because i don’t know about raycasting
Thank you!