Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RigidBody:Rotate() got invalid argument #1 (Vector2 expected, got nil) in Line 494 of RigidBody Module #53

Open
memes231 opened this issue Aug 18, 2024 · 0 comments
Assignees

Comments

@memes231
Copy link

Hello, i tried to set the Rotate Label Zero Degrees Because of invalid argument but I got the unexpected errors like that in media

is it me or everyone?

Reproduction Steps

Step 1: Code like This

local RunService = game:GetService('RunService')
local UserInputService = game:GetService('UserInputService')
local connectino
local left = false
local right = false

local Nature2D = require(script.Parent.Nature2D.Engine)

local viewport = workspace.CurrentCamera.ViewportSize

local truckist = nil

local Engine = Nature2D.init(script.Parent)
Engine:CreateCanvas(Vector2.new(0, 0), viewport, script.Parent.Frame)

local tabel = {}

local RigidBodyFrame = script.Parent.Frame.Anchord
local Body = Engine:Create("RigidBody",{
	Object = RigidBodyFrame,
	Collidable = true,
	Anchored = true
})

for i, v in pairs(script.Parent.Frame.NonAnchored:GetChildren()) do
	table.insert(tabel, Engine:Create("RigidBody",{
		Object = v,
		Collidable = true,
		Anchored = false
	}))
end

local chars = script.Parent.Frame.Character
local player = Engine:Create("RigidBody",{
	Object = chars,
	Collidable = true,
	Anchored = false,
	CanRotate = true
})

Engine:Start()

for is, vicc in pairs(script.Parent.Frame.NonAnchored:GetChildren()) do
vicc.UIDragDetector.DragStart:Connect(function()
	connectino = RunService.RenderStepped:Connect(function(Times)
		local mousepos = UserInputService:GetMouseLocation()
			tabel[is]:SetPosition(mousepos.X, mousepos.Y)
		end)
		
		vicc.UIDragDetector.DragEnd:Connect(function()
			connectino:Disconnect()
		end)
	end)
end

UserInputService.InputEnded:Connect(function(inp)
	if inp.KeyCode == Enum.KeyCode.A then
		left = false
	elseif inp.KeyCode == Enum.KeyCode.D then
		right = false
	end
end)

RunService.RenderStepped:Connect(function()
	player:Rotate(0)
end)

UserInputService.InputBegan:Connect(function(inp)
	if inp.KeyCode == Enum.KeyCode.A then
		left = true
		while left do
			player:ApplyForce(Vector2.new(-0.3, 0))
			task.wait()
		end
	elseif inp.KeyCode == Enum.KeyCode.D then
		right = true
		while right do
			player:ApplyForce(Vector2.new(0.3, 0))
			task.wait()
		end
	elseif inp.KeyCode == Enum.KeyCode.W then
		player:ApplyForce(Vector2.new(0,-15))
	end
end)

Step 2: Now Got Errors path_to.Nature2D.Physics.RigidBody:494: invalid argument #1 (Vector2 expected, got nil)
in Line 494

Expected Behavior

image

Actual Behavior

image

Media

The Example is
image

Encounters

I got the error bug when i tried to setting rotation to zero.

Lastly

please fix this error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants