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 » Scripting Helpers
Home Search
 

Re: Help please.

Previous Thread :: Next Thread 
seanb117 is not online. seanb117
Joined: 03 Feb 2010
Total Posts: 1020
30 Dec 2013 08:33 PM
So I am working on a tool that points a turret towards the mouse using welds. It ALMOST works, it'll point to the mouse but it doesn't always do it. I hear people who made scripts that point your arm towards the mouse had the same issue, but I'm not sure how they fixed it.
Code relevant to the issue:
function move(m)
moving = true
while (moving) do
wait(0.0001)
local offset = (connector.Position - m.Hit.p)
local direction = offset.Unit
local angle = math.atan2(direction.Z, direction.X) + (math.pi/2)
local angle2 = math.asin(direction.Y)
weld.C0 = CFrame.new(weld.C0.p) * CFrame.Angles(0, angle, 0)
weld2.C0 = CFrame.new(weld2.C0.p) * CFrame.Angles(angle2, 0, 0)

end
end
Report Abuse
seanb117 is not online. seanb117
Joined: 03 Feb 2010
Total Posts: 1020
30 Dec 2013 08:36 PM
I meant this:
function move(m)
moving = true
while (moving) do
wait(0.0001)
local offset = (connector.Position - m.Hit.p)
local direction = offset.Unit
local angle = math.atan2(direction.Z, direction.X) + math.pi
local angle2 = math.asin(direction.Y)
weld.C0 = CFrame.new(weld.C0.p) * CFrame.Angles(0, angle, 0)
weld2.C0 = CFrame.new(weld2.C0.p) * CFrame.Angles(angle2, 0, 0)

end
end

(math.pi was divided by 2 in the other one, didn't help at all)
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
30 Dec 2013 08:37 PM
How are you calling this? Mouse.Move?
Report Abuse
seanb117 is not online. seanb117
Joined: 03 Feb 2010
Total Posts: 1020
30 Dec 2013 08:41 PM
When the tool is selected. So the turret automatically points towards the mouse. It works fine if on a axis, but if it's(the vehicle) is turned around, it does the inverse.
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
30 Dec 2013 08:42 PM
try setting the position to the part itself, instead of C0.p
Report Abuse
seanb117 is not online. seanb117
Joined: 03 Feb 2010
Total Posts: 1020
30 Dec 2013 08:50 PM
It sent the turret flying..and killed my character in the process.
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
30 Dec 2013 08:53 PM
I don't get this
"weld.C0 = CFrame.new(weld.C0.p) * CFrame.Angles(0, angle, 0)
weld2.C0 = CFrame.new(weld2.C0.p) * CFrame.Angles(angle2, 0, 0) "

You have 2 welds? and you want the second weld to aim up/down and the first to aim sideways?
Report Abuse
seanb117 is not online. seanb117
Joined: 03 Feb 2010
Total Posts: 1020
30 Dec 2013 08:58 PM
Weld2, the up/down one, works perfectly fine. The first weld only works when it's in a good position.

Feel free to follow me here to see what i mean:
http://www.roblox.com/Vehicle-Testing-Place-place?id=128389060
Report Abuse
seanb117 is not online. seanb117
Joined: 03 Feb 2010
Total Posts: 1020
30 Dec 2013 09:05 PM
Oh and the welds are in two different brick, affecting two different bricks.
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
30 Dec 2013 09:07 PM
It seems reversed, try removing the + math.pi
Report Abuse
seanb117 is not online. seanb117
Joined: 03 Feb 2010
Total Posts: 1020
30 Dec 2013 09:12 PM
Thats the thing, if I do. The exact opposite happens.
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
30 Dec 2013 09:16 PM
I'll try to help tomorrow i gotta go
Report Abuse
seanb117 is not online. seanb117
Joined: 03 Feb 2010
Total Posts: 1020
30 Dec 2013 09:38 PM
Okay, well thank you.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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