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
 

Re: Mouse to Motor

Previous Thread :: Next Thread 
VineyardVine is not online. VineyardVine
Joined: 20 Nov 2010
Total Posts: 904
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
VineyardVine is not online. VineyardVine
Joined: 20 Nov 2010
Total Posts: 904
02 Sep 2015 07:35 PM
bump
Report Abuse
Seizurezxzz is not online. Seizurezxzz
Joined: 12 Feb 2013
Total Posts: 1297
02 Sep 2015 07:42 PM
It's easier to do this in a tool.
Just a little tiny tip.
Report Abuse
VineyardVine is not online. VineyardVine
Joined: 20 Nov 2010
Total Posts: 904
02 Sep 2015 07:54 PM
You mean to motor piece in the tool or what?
Report Abuse
Seizurezxzz is not online. Seizurezxzz
Joined: 12 Feb 2013
Total Posts: 1297
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
MrJoeyJoeJoey is not online. MrJoeyJoeJoey
Joined: 20 Aug 2011
Total Posts: 20787
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
Seizurezxzz is not online. Seizurezxzz
Joined: 12 Feb 2013
Total Posts: 1297
02 Sep 2015 07:58 PM
k then explain
Report Abuse
VineyardVine is not online. VineyardVine
Joined: 20 Nov 2010
Total Posts: 904
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
MrJoeyJoeJoey is not online. MrJoeyJoeJoey
Joined: 20 Aug 2011
Total Posts: 20787
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
MrJoeyJoeJoey is not online. MrJoeyJoeJoey
Joined: 20 Aug 2011
Total Posts: 20787
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
VineyardVine is not online. VineyardVine
Joined: 20 Nov 2010
Total Posts: 904
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
VineyardVine is not online. VineyardVine
Joined: 20 Nov 2010
Total Posts: 904
03 Sep 2015 03:27 PM
Joey how would I apply that to a Y axis rotate joint.

Report Abuse
nox7 is not online. 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
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