travddm
|
  |
| Joined: 29 Mar 2012 |
| Total Posts: 926 |
|
|
| 15 Apr 2014 12:22 PM |
So, I've been developing a space game called Galactic Rift, and the actual flying portion of it is coming along very nicely except for the Camera. Now, I want the camera's roll to mimic that of the Z rotation of the player's torso, which in itself is frustrating enough. Atop of mimicking the Z rotation, it has to detect when the torso is upside down, X rotation AND Z rotation.. I just can't seem to figure this out, I've been stuck on it for a day.
http://www.roblox.com/Space-Flight-Testing-place?id=153464389
I know that Oysi knows how to do this, but I fear he wouldn't enjoy me contacting him about it very much. |
|
|
| Report Abuse |
|
|
roxmat
|
  |
| Joined: 10 Jun 2011 |
| Total Posts: 66 |
|
|
| 15 Apr 2014 12:26 PM |
| You know how to grab a players camera, correct? |
|
|
| Report Abuse |
|
|
travddm
|
  |
| Joined: 29 Mar 2012 |
| Total Posts: 926 |
|
|
| 15 Apr 2014 12:28 PM |
| Yes, I already have it set to interpolate automatically to the player's position. The CoordinateFrame mimics the Y Rotation, but not X past 180 radians and the Z rotation. |
|
|
| Report Abuse |
|
|
Bebee2
|
  |
| Joined: 17 May 2009 |
| Total Posts: 3985 |
|
|
| 15 Apr 2014 12:29 PM |
Setting (Z?) Rotation of Camera (lolwhynot.) http://wiki.roblox.com/index.php?title=SetRoll_(Method)
Getting an angle from CFrame: http://wiki.roblox.com/index.php?title=Euler_angles#Converting_a_CFrame_to_Euler_angles
|
|
|
| Report Abuse |
|
|
roxmat
|
  |
| Joined: 10 Jun 2011 |
| Total Posts: 66 |
|
|
| 15 Apr 2014 12:32 PM |
Hmm, Seems like a tricky one for me. Sorry man. :(
Have you checked out here? http://wiki.roblox.com/index.php/Camera_manipulation |
|
|
| Report Abuse |
|
|
Bebee2
|
  |
| Joined: 17 May 2009 |
| Total Posts: 3985 |
|
| |
|
roxmat
|
  |
| Joined: 10 Jun 2011 |
| Total Posts: 66 |
|
|
| 15 Apr 2014 12:35 PM |
:O woah, that link would be useful!
|
|
|
| Report Abuse |
|
|
travddm
|
  |
| Joined: 29 Mar 2012 |
| Total Posts: 926 |
|
|
| 15 Apr 2014 01:05 PM |
@Bebee2
Thank you for the links, but that wasn't what I was looking for. I already had the SetRoll, but I do not know how to determine what to put in there to make it follow the z AND x rotations. Y'know, for going upside down.. |
|
|
| Report Abuse |
|
|
RoflBread
|
  |
| Joined: 18 Jun 2009 |
| Total Posts: 3803 |
|
|
| 15 Apr 2014 01:14 PM |
pitch, yaw, roll = torso.CFrame:toEulerAngles()
That said, you could probably get that data from the .Rotation property of the torso anyway. So, roll = torso.Rotation.z
Then all you'd have to do is
camera:SetRoll(roll)
every frame.
Using the .RenderStepped event of the RunService, you can get smooth camera motion. |
|
|
| Report Abuse |
|
|
Bebee2
|
  |
| Joined: 17 May 2009 |
| Total Posts: 3985 |
|
|
| 15 Apr 2014 01:17 PM |
Alright
SetRoll TiltUnits
SetRoll - Rotates Z Axis (RADIAN ARGUMENTS. So like math.rad(45) or math.pi/2 HAS to be on Scriptable CameraType) TiltUnits - Rotates X Axis (Radian argument again)
In the Euler Angles link, I give you how to get the X,Y, and Z angles from a CFrame.
Only problem being that TiltUnits tilts by how much the parameter is. This means you have to get the delta (difference) X angle of the Torso and the Camera then tilt... And I'm not sure getting the X angle from Camera.CoordinateFrame is accurate enough for that. |
|
|
| Report Abuse |
|
|
travddm
|
  |
| Joined: 29 Mar 2012 |
| Total Posts: 926 |
|
|
| 15 Apr 2014 01:42 PM |
Thank you.
Egghhhghg, math. |
|
|
| Report Abuse |
|
|
travddm
|
  |
| Joined: 29 Mar 2012 |
| Total Posts: 926 |
|
|
| 15 Apr 2014 02:08 PM |
| TiltUnits doesn't seem to be helping too much, it doesn't allow the camera to go upside down, unlike SetRoll.. Still confuzzled. |
|
|
| Report Abuse |
|
|
travddm
|
  |
| Joined: 29 Mar 2012 |
| Total Posts: 926 |
|
| |
|
Bebee2
|
  |
| Joined: 17 May 2009 |
| Total Posts: 3985 |
|
|
| 15 Apr 2014 03:24 PM |
TiltUnits is X-Axis
SetRoll is Z-Axis |
|
|
| Report Abuse |
|
|
travddm
|
  |
| Joined: 29 Mar 2012 |
| Total Posts: 926 |
|
|
| 15 Apr 2014 03:52 PM |
| I know what TiltUnits and SetRoll are, TiltUnits won't allow the camera to be upside down unlike SetRoll, and the X rotational axis is accessible by the CoordinateFrame to the extent of 180 radians. I just need help with using SetRoll to satisfy the rotation of the player's torso exactly. |
|
|
| Report Abuse |
|
|
travddm
|
  |
| Joined: 29 Mar 2012 |
| Total Posts: 926 |
|
| |
|
Bebee2
|
  |
| Joined: 17 May 2009 |
| Total Posts: 3985 |
|
|
| 16 Apr 2014 12:00 AM |
Use the Euler Angles link I sent you to get the Z angle in radians of the torso.
Set SetRoll to that value.
Is there more to it :o? |
|
|
| Report Abuse |
|
|
travddm
|
  |
| Joined: 29 Mar 2012 |
| Total Posts: 926 |
|
|
| 16 Apr 2014 01:52 PM |
| There is more to it, since the ship can go upside down using the X rotational axis, I have to account for that, too. This requires math and some well-placed if statements. You see, 180 radians is the max you can tilt the camera on the X axis before it reverts. |
|
|
| Report Abuse |
|
|
travddm
|
  |
| Joined: 29 Mar 2012 |
| Total Posts: 926 |
|
|
| 16 Apr 2014 03:47 PM |
| Bump. Mathmathmathmath. It'd probably help to look at the place I've put in the original post. |
|
|
| Report Abuse |
|
|
powertool
|
  |
| Joined: 01 Feb 2008 |
| Total Posts: 3771 |
|
|
| 16 Apr 2014 03:56 PM |
When the camera points vertical, why not flip the roll to 180 degrees from where it is, then address the camera in mirror image?
--Shira |
|
|
| Report Abuse |
|
|
travddm
|
  |
| Joined: 29 Mar 2012 |
| Total Posts: 926 |
|
|
| 16 Apr 2014 04:21 PM |
| I've been trying to do that, but the rotation is really hard to do that with. Like.. Instead of a simple if statement, you'd have to figure out the exact conditions of using the X rotational axis to make the thing go upside down. I'm frankly confused to heck about it. I've tried and tried, but the conditions always seem to change. |
|
|
| Report Abuse |
|
|
travddm
|
  |
| Joined: 29 Mar 2012 |
| Total Posts: 926 |
|
| |
|
travddm
|
  |
| Joined: 29 Mar 2012 |
| Total Posts: 926 |
|
| |
|
travddm
|
  |
| Joined: 29 Mar 2012 |
| Total Posts: 926 |
|
| |
|
travddm
|
  |
| Joined: 29 Mar 2012 |
| Total Posts: 926 |
|
| |
|