Jump to content

Perpetually rotating hinge.


DerRidda
 Share

Recommended Posts

How would I go about setting up a perpetually rotating hinge joint?

Once its reaches the SetAngle value, it will stop and I have no clue how to cleanly reset it without interrupting the process. The dirty way is to use GetAngle to capture the value just as it nears the SteAngle value and add a ton more to the SetAngle value and just add some more on top but that will break eventually as the numerical value reaches the maximum for floats.

 

Which might take a ton of time but I truly hate conceptually broken code.

 

Anyone got any ideas?

 

Script.pin = Vec3(0,0,1) --Vec3 "Hinge Pin"
Script.limitsenabled=false--bool "Enable limits"
Script.limits = Vec2(-45,45) --Vec2 "Limits"
Script.parent= nil --entity "Parent entity"

function Script:Start()
startrotation = self.entity:GetRotation()

local pos = self.entity:GetPosition()
local parent_pos = self.parent:GetPosition()
local abs_pos = pos + parent_pos
self.joint = Joint:Hinge(abs_pos.x, abs_pos.y, abs_pos.z, self.pin.x, self.pin.y, self.pin.z, self.entity, self.parent)
if self.limitsenabled then self.joint:EnableLimits() end
self.joint:SetAngle(1080)
self.joint:EnableMotor()
self.joint:SetMotorSpeed(360)
self.joint:SetLimits(self.limits.x,self.limits.y)
end

function Script:UpdateWorld()
--feed me! 
end

Link to comment
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.

Guest
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.

 Share

×
×
  • Create New...