|
| 02 Sep 2015 06:36 PM |
I have this Motor configured to turn horizontally
local horizontalmotor = game.Workspace.HorizontalPart.Motor
I want the motor to turn toward the mouse position on every frame rendered
local player = game.Player.LocalPlayer local mouse = player:GetMouse()
game:GetService("RunService").RenderStepped:connect(function()
local mouseposition = mouse.Hit.p
end)
I got this far and then I realized that I have no clue how to actually do this. Can anyone point me on the right track? |
|
|
| Report Abuse |
|
|
| |
|
|
| 02 Sep 2015 07:42 PM |
It's easier to do this in a tool. Just a little tiny tip. |
|
|
| Report Abuse |
|
|
|
| 02 Sep 2015 07:54 PM |
| You mean to motor piece in the tool or what? |
|
|
| Report Abuse |
|
|
|
| 02 Sep 2015 07:56 PM |
| I mean like, when ever you ADS, make a ImageGui appear on the screen, appearing as though you're ADS but the gun is in the center of your face. |
|
|
| Report Abuse |
|
|
|
| 02 Sep 2015 07:57 PM |
"It's easier to do this in a tool. Just a little tiny tip."
NO IT ISN'T YOU MORON IT IS THE SAME DIFFICULTY, IF NOT EASIER! |
|
|
| Report Abuse |
|
|
| |
|
|
| 02 Sep 2015 07:58 PM |
... Not really what I am looking for I am trying to spin a cannon which is separate from the character with a preexisting motor |
|
|
| Report Abuse |
|
|
|
| 02 Sep 2015 07:59 PM |
Well for one, you dont want to use a motor, if anything use a body gyro + hindge
Gyro.cframe = CFrame.new(part.Position,Vector3.new(mouse.Hit.X,part.Position.Y,mouse.Hit.Z)) |
|
|
| Report Abuse |
|
|
|
| 02 Sep 2015 08:00 PM |
local player = game.Players.LocalPlayer local mouse = player:GetMouse() local gyro = (PATH TO GYRO) local part = (PATH TO PART) game["Run Service"]:BindToRenderStep("Point",1,function() gyro.cframe = CFrame.new(part.Position,Vector3.new(mouse.Hit.X,part.Position.Y,mouse.Hit.Z)) end |
|
|
| Report Abuse |
|
|
|
| 02 Sep 2015 08:01 PM |
I don't see how a tool would make it any easier...
It would just make the code slightly longer by setting up equipped variables |
|
|
| Report Abuse |
|
|
|
| 03 Sep 2015 03:27 PM |
Joey how would I apply that to a Y axis rotate joint.
|
|
|
| Report Abuse |
|
|
nox7
|
  |
| Joined: 29 Aug 2008 |
| Total Posts: 27467 |
|
|
| 03 Sep 2015 04:22 PM |
local Motor = ... local Torso = Player.Character.Torso
function PointDesiredAngle(MousePosition) local Omega = Vector3.new(Mouse.Hit.p.X, 0, Mouse.Hit.p.Z) local RightVector = Torso.CFrame:vectorToWorldSpace(Vector3.new(1,0,0)) local Angle = (Omega.unit:Dot(RightVector))/(Omega.unit.magnitude * RightVector.unit.magnitude) -- Magnitudes should be one, but just in case Motor.DesiredAngle = math.acos(Angle) end |
|
|
| Report Abuse |
|
|