eqisJoin Date: 2008-12-31 Post Count: 295 |
Don't suppose anyone knows of a way to make a gun move up and down with the cursor in first person mode? |
|
M4LLARDJoin Date: 2012-08-13 Post Count: 3201 |
Some people to know how to, yes. |
|
eqisJoin Date: 2008-12-31 Post Count: 295 |
I know some people do, that's why I'm asking. |
|
M4LLARDJoin Date: 2012-08-13 Post Count: 3201 |
You asked if people knew a way. I answered that. |
|
eqisJoin Date: 2008-12-31 Post Count: 295 |
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. |
|
|
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 ) |
|
|
Oops, divide by camera.Viewport.Y/2 not camera.Viewport.Size.Y |
|
CasualistJoin Date: 2014-06-26 Post Count: 4443 |
For first person, you'll be doing everything with the camera's lookvector relative to the x-z plane. |
|
|
Also, by camera.Viewport.H I meant camera.Viewport.Y |
|
eqisJoin Date: 2008-12-31 Post Count: 295 |
Thanks pear. |
|
|
Also my formula only works for when you're not in first person, I'll leave it up to you to convert it. |
|
|
Eh, I'll be nice:
radians = math.rad( 45 ) * ( math.acos( mouse.Hit.lookVector:Dot( Vector3.new( 0, 1, 0 ) ) ) / math.pi - .5 ) |
|
|
Correction:
radians = math.rad( 45 ) * -( math.acos( mouse.Hit.lookVector:Dot( Vector3.new( 0, 1, 0 ) ) ) / math.pi - .5 ) |
|
eqisJoin Date: 2008-12-31 Post Count: 295 |
Pear, do you know how to get the Y from the mouse in first person? |
|
|
^ The mouse is locked in the center of the screen in first person. See the 2nd formula I posted. |
|
CasualistJoin Date: 2014-06-26 Post Count: 4443 |
@pear Why wouldn't you just use the camera's lookvector? |
|
|
^ Because I don't want to have to type camera.CoordinateFrame.lookVector when I can type mouse.Hit.lookVector to do the same thing. |
|