louiskk
|
  |
| Joined: 31 Dec 2008 |
| Total Posts: 228 |
|
|
| 10 Aug 2015 02:45 PM |
| Don't suppose anyone knows of a way to make a gun move up and down with the cursor in first person mode? |
|
|
| Report Abuse |
|
|
|
| 10 Aug 2015 02:46 PM |
| Some people to know how to, yes. |
|
|
| Report Abuse |
|
|
louiskk
|
  |
| Joined: 31 Dec 2008 |
| Total Posts: 228 |
|
|
| 10 Aug 2015 02:48 PM |
| I know some people do, that's why I'm asking. |
|
|
| Report Abuse |
|
|
|
| 10 Aug 2015 02:51 PM |
| You asked if people knew a way. I answered that. |
|
|
| Report Abuse |
|
|
louiskk
|
  |
| Joined: 31 Dec 2008 |
| Total Posts: 228 |
|
|
| 10 Aug 2015 02:53 PM |
| Perhaps if you used common sense you'd realise I wanted an answer to my question, not you telling me that there is someone in our corporeal plane that has the knowledge. |
|
|
| Report Abuse |
|
|
|
| 10 Aug 2015 02:56 PM |
Step 1: Get player's mouse Step 2: Get height of screen (obtainable through camera.ViewportSize.h) Step 3: Get y position of mouse in a move event Step 4: Use the following formula to get the degrees in radians that you should rotate the tool on the desired axis:
radians = math.rad( 45 ) * ( ( -( camera.ViewportSize.Y / 2 - y ) )/ camera.Viewport.Size.Y ) |
|
|
| Report Abuse |
|
|
|
| 10 Aug 2015 02:57 PM |
| Oops, divide by camera.Viewport.Y/2 not camera.Viewport.Size.Y |
|
|
| Report Abuse |
|
|
Casualist
|
  |
| Joined: 26 Jun 2014 |
| Total Posts: 4443 |
|
|
| 10 Aug 2015 02:58 PM |
| For first person, you'll be doing everything with the camera's lookvector relative to the x-z plane. |
|
|
| Report Abuse |
|
|
|
| 10 Aug 2015 02:58 PM |
| Also, by camera.Viewport.H I meant camera.Viewport.Y |
|
|
| Report Abuse |
|
|
louiskk
|
  |
| Joined: 31 Dec 2008 |
| Total Posts: 228 |
|
| |
|
|
| 10 Aug 2015 02:59 PM |
| Also my formula only works for when you're not in first person, I'll leave it up to you to convert it. |
|
|
| Report Abuse |
|
|
|
| 10 Aug 2015 03:08 PM |
Eh, I'll be nice:
radians = math.rad( 45 ) * ( math.acos( mouse.Hit.lookVector:Dot( Vector3.new( 0, 1, 0 ) ) ) / math.pi - .5 ) |
|
|
| Report Abuse |
|
|
|
| 10 Aug 2015 03:09 PM |
Correction:
radians = math.rad( 45 ) * -( math.acos( mouse.Hit.lookVector:Dot( Vector3.new( 0, 1, 0 ) ) ) / math.pi - .5 ) |
|
|
| Report Abuse |
|
|
louiskk
|
  |
| Joined: 31 Dec 2008 |
| Total Posts: 228 |
|
|
| 10 Aug 2015 03:12 PM |
| Pear, do you know how to get the Y from the mouse in first person? |
|
|
| Report Abuse |
|
|
|
| 10 Aug 2015 03:12 PM |
| ^ The mouse is locked in the center of the screen in first person. See the 2nd formula I posted. |
|
|
| Report Abuse |
|
|
Casualist
|
  |
| Joined: 26 Jun 2014 |
| Total Posts: 4443 |
|
|
| 10 Aug 2015 03:15 PM |
| @pear Why wouldn't you just use the camera's lookvector? |
|
|
| Report Abuse |
|
|
|
| 10 Aug 2015 03:42 PM |
| ^ Because I don't want to have to type camera.CoordinateFrame.lookVector when I can type mouse.Hit.lookVector to do the same thing. |
|
|
| Report Abuse |
|
|