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: Changing Camera CoordinateFrame based on part position

Previous Thread :: Next Thread 
Widths is not online. Widths
Joined: 12 Aug 2014
Total Posts: 41286
10 Aug 2016 08:01 PM
So basically I want to set the camera so it looks at the position of a part, but I want it so that the player cannot move the camera at ALL in any direction zoom in etc.

so I'm setting:

workspace.CurrentCamera.CoordinateFrame = CFrame.new(workspace.Arenas.Arena1.Cave.Camera.Position)

and changing the CameraType to Scriptable

however, sometimes the camera gets flipped and faces the wrong way

how can I make it always face the same direction and look outwards from the part?


-iJava
Report Abuse
kools is not online. kools
Joined: 11 Jan 2009
Total Posts: 1659
10 Aug 2016 08:02 PM
What do you define as outwards from a part? The front face, the back face?
Report Abuse
Widths is not online. Widths
Joined: 12 Aug 2014
Total Posts: 41286
10 Aug 2016 08:03 PM
BackSurface


-YOSkater
Report Abuse
Widths is not online. Widths
Joined: 12 Aug 2014
Total Posts: 41286
10 Aug 2016 08:04 PM
Is there a way to define the face? That isn't really an issue since I could rotate it 180 degrees

but I mean


this is the part:

O


this is what you see:

/
O/
\
\

(probably gonna look wrong)


-iJava
Report Abuse
Widths is not online. Widths
Joined: 12 Aug 2014
Total Posts: 41286
10 Aug 2016 08:05 PM
Nvm it's the back side


-YOSkater
Report Abuse
kools is not online. kools
Joined: 11 Jan 2009
Total Posts: 1659
10 Aug 2016 08:07 PM
The pseudocode looks like this (I believe):

local partcframe -- The CFrame of the part

CFrame.new(partcframe.p, partcframe:vectorToWorldSpace(partcframe.p + Vector3.new(-1, 0, 0)))

Though I am very bad with CFrame math.

I would fiddle with the vector being added to the parts position.

I think that will work ....
Report Abuse
Tynezz is not online. Tynezz
Joined: 28 Apr 2014
Total Posts: 4945
10 Aug 2016 08:10 PM
local cam=game.Workspace.CurrentCamera
while cam.CameraType~='Scriptable' do cam.CameraType='Scriptable' wait() end

cam.CFrame=CFrame.new((target.CFrame*CFrame.new(0,0,30)).p,target.Position)
Report Abuse
Widths is not online. Widths
Joined: 12 Aug 2014
Total Posts: 41286
10 Aug 2016 08:14 PM
Neither solution has worked for me, but thanks for the help

They still put you at different angles depending on what direction you were facing/where you were in relation to the part before changing your camera


-iJava
Report Abuse
Tynezz is not online. Tynezz
Joined: 28 Apr 2014
Total Posts: 4945
10 Aug 2016 08:18 PM
cam.CFrame=CFrame.new(target.Position)*CFrame.new(0,0,20)
cam.CFrame=CFrame.new(cam.CFrame.p,target.Position)
Report Abuse
Widths is not online. Widths
Joined: 12 Aug 2014
Total Posts: 41286
10 Aug 2016 08:23 PM
Still having the same issue, this is my full code:

local cam=workspace.CurrentCamera
local target = workspace.Arenas.Arena1.Cave.Camera
cam.CFrame=CFrame.new(target.Position)*CFrame.new(0,0,20)
cam.CFrame=CFrame.new(cam.CFrame.p,target.Position)


I just need it to be exactly the same each time, regardless of your relative position compared to the target


-iJava
Report Abuse
Tynezz is not online. Tynezz
Joined: 28 Apr 2014
Total Posts: 4945
10 Aug 2016 08:25 PM
So what are you trying to really do?
Report Abuse
Widths is not online. Widths
Joined: 12 Aug 2014
Total Posts: 41286
10 Aug 2016 08:26 PM
I just want you to be forced to look at a certain area of my game without being able to move your camera at all, but from the same angle every time, so I'm setting the coordinateframe equal to the position of a part, but the angle is different every time


-iJava
Report Abuse
kools is not online. kools
Joined: 11 Jan 2009
Total Posts: 1659
10 Aug 2016 08:36 PM
What I would suggest, and what might potentially make it easier to solve your problem would be to define these objects with two parts. The first part is where the camera will be, the 2nd part will define what the camera will be aligned with.
Report Abuse
Widths is not online. Widths
Joined: 12 Aug 2014
Total Posts: 41286
10 Aug 2016 08:44 PM
What do you mean?


-iJava
Report Abuse
kools is not online. kools
Joined: 11 Jan 2009
Total Posts: 1659
10 Aug 2016 08:49 PM
The first object would be the player's camera would be seated, and the second part the camera is forced to put dead center.

CFrame.new(position1, position2) does this.
/
/
/
/
/
1 ------> 2
\
\
\
\
\

1 is the position, 2 is where it is forced to look at.
Report Abuse
Lord_Narwhal is not online. Lord_Narwhal
Joined: 05 May 2012
Total Posts: 3242
10 Aug 2016 08:50 PM
can't you just set the subject to the part and lock the camera


Formerly xXTheRobotXx, add 13,349 posts
Report Abuse
kools is not online. kools
Joined: 11 Jan 2009
Total Posts: 1659
10 Aug 2016 08:52 PM
Or that ^

No need to use CFrame(1,2)

CameraSubject does that for you. But you still have two objects.
Report Abuse
Lord_Narwhal is not online. Lord_Narwhal
Joined: 05 May 2012
Total Posts: 3242
10 Aug 2016 08:53 PM
i would just do this

camera.CameraType = "Scriptable"
camera.CameraSubject = part
local cf = camera.CFrame

game:GetService("RunService").RenderStepped:connect(function()
camera.CFrame = cf
end)


Formerly xXTheRobotXx, add 13,349 posts
Report Abuse
Widths is not online. Widths
Joined: 12 Aug 2014
Total Posts: 41286
10 Aug 2016 08:55 PM
how do I lock the camera?


-iJava
Report Abuse
Lord_Narwhal is not online. Lord_Narwhal
Joined: 05 May 2012
Total Posts: 3242
10 Aug 2016 08:57 PM
render stepped + constantly setting the cframe

my code might work


Formerly xXTheRobotXx, add 13,349 posts
Report Abuse
Widths is not online. Widths
Joined: 12 Aug 2014
Total Posts: 41286
10 Aug 2016 08:57 PM
wouldn't that be super inefficient...?


-iJava
Report Abuse
Lord_Narwhal is not online. Lord_Narwhal
Joined: 05 May 2012
Total Posts: 3242
10 Aug 2016 09:00 PM
there's no easy one trick method to lock the camera 3rd person(unless there is, i haven't seen one yet)

so yes, you have to do it in a dumb inefficient way


Formerly xXTheRobotXx, add 13,349 posts
Report Abuse
Lord_Narwhal is not online. Lord_Narwhal
Joined: 05 May 2012
Total Posts: 3242
10 Aug 2016 09:03 PM
actually try this

without render step

camera.CameraSubject = part
camera.CameraType = "Fixed"


Formerly xXTheRobotXx, add 13,349 posts
Report Abuse
Widths is not online. Widths
Joined: 12 Aug 2014
Total Posts: 41286
10 Aug 2016 09:06 PM
You can move fixed camera


-iJava
Report Abuse
Lord_Narwhal is not online. Lord_Narwhal
Joined: 05 May 2012
Total Posts: 3242
10 Aug 2016 09:07 PM
render stepped it is


Formerly xXTheRobotXx, add 13,349 posts
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