Working on a Visual Scripting game! - Devlog 5

Hello everyone!

Today I was so busy so I did not have much time to work on the game. Whatever, I’ve quickly added a way to duplicate any object in your game.

Just click the white button with a black duplicate icon on it.

Also fixed some bugs with resizing and started working on the rotate tool (it is way harder than I thought!)

It works around 50% okay.

I made so much progress during these 5 days I’m quite impressed by myself! I hope I can keep my promise and release an early access by the end of March.

Interested?

Please let me know if you’d like to get tagged in future devlogs.
Also, any ideas are welcome!

Have a great day!


Tagged people: @TattyDogeGaming

4 Likes

If you need, I have did long time ago this script which handles both regular HandleAdornment and RotateHandleAdornment.

local handle = script.Parent --HandleAdornment
local archandle = script.Parent.Parent.Rotate --RotateHandleAdornment
local Mode = "Move"
local ContextActionService = game:GetService("ContextActionService")
local Target = nil
local Player = game:GetService("Players").LocalPlayer
local mouse = Player:GetMouse()
--for rotation
local increment = 5
local lastCFrame = nil
--for moving/resizing
local oldDelta = 0
local snap = 0.25
local smallestSize = 0.25

local surfaceAxis = {
	[Enum.NormalId.Top] = 'Y',
	[Enum.NormalId.Bottom] = 'Y',
	[Enum.NormalId.Front] = 'Z',
	[Enum.NormalId.Back] = 'Z',
	[Enum.NormalId.Left] = 'X',
	[Enum.NormalId.Right] = 'X'
}

local function onSwitch1(actionName, userInputState, input)
	if (userInputState == Enum.UserInputState.Begin) then
		if Mode == "Move" then
			Mode = "Resize"
			handle.Style = "Resize"
			handle.Color3 = Color3.fromRGB(255, 0, 255)
		elseif Mode == "Resize" then
			Mode = "Rotate"
			archandle.Adornee = handle.Adornee
			handle.Adornee = nil
		elseif Mode == "Rotate" then
			Mode = "Move"
			handle.Adornee = archandle.Adornee
			archandle.Adornee = nil
			handle.Style = "Movement"
			handle.Color3 = Color3.fromRGB(255, 255, 0)
		end
	end
end

local function onSwitch2(actionName, userInputState, input)
	if (userInputState == Enum.UserInputState.Begin) then
		if Mode == "Move" then
			Mode = "Rotate"
			archandle.Adornee = handle.Adornee
			handle.Adornee = nil
		elseif Mode == "Resize" then
			Mode = "Move"
			handle.Style = "Movement"
			handle.Color3 = Color3.fromRGB(255, 255, 0)
		elseif Mode == "Rotate" then
			Mode = "Resize"
			handle.Adornee = archandle.Adornee
			archandle.Adornee = nil
			handle.Style = "Resize"
			handle.Color3 = Color3.fromRGB(255, 0, 255)
		end
	end
end

handle.MouseDrag:Connect(function(face, distance)
	local delta = distance - oldDelta
	if math.abs(delta * 1.125) >= snap then
		if Mode == "Move" then
			delta = math.round(delta / snap) * snap
			local direction = Vector3.fromNormalId(face)
			local move = Vector3.new(direction.X, direction.Y, direction.Z)
			local endPosition = handle.Adornee.Position + move * delta
			handle.Adornee:PivotTo(handle.Adornee.CFrame * CFrame.new(direction * delta))
			oldDelta = distance
		elseif Mode == "Resize" then
			delta = math.round(delta / snap) * snap
			local direction = Vector3.fromNormalId(face)
			local size = Vector3.new(math.abs(direction.X), math.abs(direction.Y), math.abs(direction.Z))
			local endSize = handle.Adornee.Size + size * delta
			if endSize[surfaceAxis[face]] >= smallestSize then
				handle.Adornee.Size = endSize
				handle.Adornee:PivotTo(handle.Adornee.CFrame * CFrame.new(direction / 2 * delta))
				oldDelta = distance
			end
		end		
	end
end)

handle.MouseButton1Up:Connect(function()
	oldDelta = 0
end)

function round(number)
	return math.floor((number / increment) + 0.5) * increment
end
function AngleFromAxis(axis, r)
	local relativeAngle = math.rad(round(math.deg(r)))

	return axis == Enum.Axis.X and {relativeAngle, 0, 0} 
		or axis == Enum.Axis.Y and {0, relativeAngle, 0} 
		or axis == Enum.Axis.Z and {0, 0, relativeAngle}
end

archandle.MouseDrag:Connect(function(axis, relativeAngle, delta)
	archandle.Adornee.CFrame = lastCFrame * CFrame.Angles(unpack(AngleFromAxis(axis, relativeAngle)))
end)

archandle.MouseButton1Down:Connect(function()
	lastCFrame = archandle.Adornee.CFrame
end)

mouse.Button1Down:Connect(function()
	if mouse.Target == Target or mouse.Target == nil then
		Target = nil
		handle.Adornee = nil
		archandle.Adornee = nil
	else
		Target = mouse.Target
		if Mode == "Move" or Mode == "Resize" then
			handle.Adornee = Target
		elseif Mode == "Rotate" then
			archandle.Adornee = Target
		end
	end
end)

ContextActionService:BindAction("switch1", onSwitch1, false, Enum.KeyCode.Z)
ContextActionService:BindAction("switch2", onSwitch2, false, Enum.KeyCode.X)

(Note - it should be parented under HandleAdornment to show work in this example. You will need to rewrite it for your use-case)

2 Likes

Thank you so much! I’ll definitely use this for my case even if I have to rewrite it.

1 Like

Sorry for not making devlogs for a long time!
I’m still working on the game I just did not have anything to show off as I’m mainly debugging features and working on the UI.
I plan to post some progress on the weekend.

1 Like

I think it would be fun if there was also a way to script normally if you don’t prefer the original concept of visual scripting, it would also be cool if there you could make custom meshes using the game alone. I am really interested where this project is going and I am going to gladly play it when it releases!