generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

[ Content Deleted ]

Previous Thread :: Next Thread 
MM233 is not online. MM233
Joined: 19 Jun 2008
Total Posts: 925
02 Jan 2012 01:20 PM
I'm making a turret on a vehical using a Motor6D. I need full 360* rotation.
It is controlled with a hopperbin. Script:

local tool = script.Parent
local HCv = tool.HCValue
local hingeA = HCv.Value:findFirstChild("HingeA1")

tool.Selected:connect(function (mouse)
while wait(0.1) do
local guideD = HCv.Value.Handle.CFrame.lookVector
local a = ((hingeA.Position + guideD) - mouse.Hit.p).magnitude
local b = ((hingeA.Position - guideD) - mouse.Hit.p).magnitude
local A = mouse.Hit.p.Z - hingeA.CFrame.Z
local B = (mouse.Hit.p - hingeA.Position).magnitude
if aa <= ba then
hingeA.Motor6D.DesiredAngle = math.asin(A/B) * -1
elseif a >= b then
hingeA.Motor6D.DesiredAngle = math.asin(A/B) - 3.125
end
end
end)

tool.Deselected:connect(function ()
hingeA.Motor6D.DesiredAngle = 0
end)

The script works, but when the turret cannot rotate all the way through on the right side. This is because, when the mouse passes to the rear of the turret, the value becomes a negative number (After reaching about 1.3) and the Motor6D rotates back to 0 and then through to negative numbers to get to the new position. I need it to go directly from the aproximate 1.3 limit into the negative numbers, with out rotating all the way back around.
Report Abuse
MM233 is not online. MM233
Joined: 19 Jun 2008
Total Posts: 925
02 Jan 2012 02:31 PM
Bawmp. Am I being ignored again? o_O I thought this would be within the forum rules...
Report Abuse
Radioaktiivinen is not online. Radioaktiivinen
Joined: 25 Apr 2009
Total Posts: 18629
02 Jan 2012 02:36 PM
Just do something to convert the destination rotation to a number which doesnt go around (like if its negative, make it a positive value that makes the same rotation or something)
Report Abuse
MM233 is not online. MM233
Joined: 19 Jun 2008
Total Posts: 925
02 Jan 2012 02:39 PM
I thought I had figured that out. One full rotation is 6.3. So subtract the current number from 6.3 and multiply by -1 and there you go. Only when I tried it, my turret spazzed. ^-^ I may have gotten something wrong...
Report Abuse
Oysi is not online. Oysi
Joined: 06 Jul 2009
Total Posts: 9058
02 Jan 2012 02:41 PM
[ Content Deleted ]
Report Abuse
MM233 is not online. MM233
Joined: 19 Jun 2008
Total Posts: 925
02 Jan 2012 03:02 PM
I'm not having problems finding the right angle, but the turret has a blind spot on the right side. I need to keep the angle under 6.3 (or -6.3) at all times to keep 0 within one rotation. If its hard to understand my problem, go to my place and climb into the seat on the right side of my Hovercraft. Then select the tool and place your mouse near the front of the hovercraft. Then slowly move your mouse around the right side the the back in a half circle, and you should see the problem.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image