Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Unexpected data passed as a first function argument

Recommended Posts

I have a function call like this:

local movementVector = Vec3(-axis.x,0,axis.y)
local camRotation = self.camera:GetRotation(true) *Vec3(0,1,0)
local rotationAngle = tonumber(math.floor(camRotation.y));
local rotatedVector = self:RotateVector(movementVector,rotationAngle)

And a function definition like this:

function Script.RotateVector(unexpectedStuff,vector3,degree)
	--For some unknown to the universe reason a table type is being passed here as a first argument	
	local cosinus = Math:Cos(degree);
	local sinus = Math:Sin(degree);
	local newX = vector3.x * cosinus - vector3.z * sinus;
	local newZ = vector3.x * sinus + vector3.z * cosinus;
	return Vec3(newX,0,newZ)	

It took me a bit of debugging to see why my Math:Cos function was getting Vec3 instead of a plain number. In the scenario above I had to put extra argument in function definition called "unexpectedStuff" as I noticed a table type is being passed to the function upon call. I have no idea why, first time I see something like that in my experience.

Attached is a full player script I encounter the issue in. 


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...