_provector Posted May 4, 2020 Share Posted May 4, 2020 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) end 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. Test.lua Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.