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 » Scripting Helpers
Home Search
 

Re: Camera Manipulation help

Previous Thread :: Next Thread 
evolvedpikachu is not online. evolvedpikachu
Joined: 18 Aug 2010
Total Posts: 10696
06 Apr 2013 11:00 PM
This works, just not the way I want it to. When I set the Camera from scriptable to Custom the camera becomes jerky and faulty. Also, my loop which adds/subtracts to the CoordinateFrame property instantly goes to that spot I'm making it go to instead of smoothly going there. What did I do? ( This is not full script )

local Player = script.Parent.Parent

function onKeyDown(key)
elseif key == "r" then
local cam = game.Workspace.CurrentCamera
local p = game.Workspace.SpawnLocation.Position
local a = cam.CoordinateFrame
print(cam.CameraType)
cam.CameraType = "Scriptable"
while cam.CoordinateFrame ~= p do
wait(0.1)
if a.X - p.X < 0 then
wait(0.1)
cam.CoordinateFrame = CFrame.new(a.X + 0.1,a.Y,a.Z)
elseif a.X - p.X > 0 then
wait(0.1)
cam.CoordinateFrame = CFrame.new(a.X - 0.1,a.Y,a.Z)
elseif a.Z - p.Z < 0 then
wait(0.1)
cam.CoordinateFrame = CFrame.new(a.X,a.Y,a.Z + 0.1)
elseif a.Z - p.Z > 0 then
wait(0.1)
cam.CoordinateFrame = CFrame.new(a.X,a.Y,a.Z - 0.1)
end
end

function onKeyUp(key)
elseif key == "r" then
local c = script.Parent.Parent.Character.Torso.Position
local pos = script.Parent.Parent.Character.Head.Position
local cam = game.Workspace.CurrentCamera
local val = Instance.new("CFrameValue",game.Workspace)
val.Value = CFrame.new(c.X,c.Y,c.Z)
local e = script.Parent.Parent:LoadCharacter()
e:MoveTo(val.Value)
val:Destroy()
end

local Mouse = Player:GetMouse()
Mouse.KeyDown:connect(onKeyDown)
Mouse.KeyUp:connect(onKeyUp)
Report Abuse
evolvedpikachu is not online. evolvedpikachu
Joined: 18 Aug 2010
Total Posts: 10696
06 Apr 2013 11:01 PM
oops, forgot to change something.

function onKeyDown(key)
elseif key == "r" then
local cam = game.Workspace.CurrentCamera
local p = game.Workspace.SpawnLocation.Position
local a = cam.CoordinateFrame
print(cam.CameraType)
cam.CameraType = "Scriptable"
while cam.CoordinateFrame ~= p do
wait(0.1)
if a.X - p.X < 0 then
wait(0.1)
cam.CoordinateFrame = CFrame.new(a.X + 0.1,a.Y,a.Z)
elseif a.X - p.X > 0 then
wait(0.1)
cam.CoordinateFrame = CFrame.new(a.X - 0.1,a.Y,a.Z)
elseif a.Z - p.Z < 0 then
wait(0.1)
cam.CoordinateFrame = CFrame.new(a.X,a.Y,a.Z + 0.1)
elseif a.Z - p.Z > 0 then
wait(0.1)
cam.CoordinateFrame = CFrame.new(a.X,a.Y,a.Z - 0.1)
end
end

function onKeyUp(key)
elseif key == "r" then
local c = script.Parent.Parent.Character.Torso.Position
local pos = script.Parent.Parent.Character.Head.Position
local cam = game.Workspace.CurrentCamera
cam.CameraType = "Custom"
cam.CoordinateFrame = CFrame.new(pos.X,pos.Y,pos.Z)
end

local Mouse = Player:GetMouse()
Mouse.KeyDown:connect(onKeyDown)
Mouse.KeyUp:connect(onKeyUp)
Report Abuse
veerstrong is not online. veerstrong
Joined: 23 Jun 2009
Total Posts: 2450
06 Apr 2013 11:01 PM
function onKeyDown(key)
elseif key == "r" then


Erm.
You mean..

function onKeyDown(key)
if key == "r" then

~One must risk everything to find the truth. Even if the truth isn't what you want it to be, it is better than living a lie.~
Report Abuse
12packkid is not online. 12packkid
Joined: 24 Jun 2011
Total Posts: 1418
06 Apr 2013 11:02 PM
^

†† -1 2 P A C K K I D-* ^◕‿◕^* - ❤True friendship is not what matters ❤-††
Report Abuse
evolvedpikachu is not online. evolvedpikachu
Joined: 18 Aug 2010
Total Posts: 10696
06 Apr 2013 11:06 PM
I said this wasn't the full script lol.
Report Abuse
bigdaddy92 is not online. bigdaddy92
Joined: 17 Jan 2010
Total Posts: 1684
06 Apr 2013 11:12 PM
That wont work

You're doing this:

if something then
function example()
elseif something_else then
blah


Stuff like that wont work without ending the function in the statement it's started in.
Report Abuse
Postured is not online. Postured
Joined: 02 Feb 2012
Total Posts: 114
06 Apr 2013 11:15 PM
For the 'tweening the camera', you might want to use camera:Interpolate()

http://wiki.roblox.com/index.php/Interpolate_(Method)
Report Abuse
evolvedpikachu is not online. evolvedpikachu
Joined: 18 Aug 2010
Total Posts: 10696
06 Apr 2013 11:18 PM
I've considered Interpolate but a person said something about "jerky camera movements".
Report Abuse
Postured is not online. Postured
Joined: 02 Feb 2012
Total Posts: 114
06 Apr 2013 11:21 PM
Actually, Interpolate is quite smooth, at least in my experience.
Report Abuse
evolvedpikachu is not online. evolvedpikachu
Joined: 18 Aug 2010
Total Posts: 10696
06 Apr 2013 11:23 PM
Second reason I don't use Interpolate is because I don't understand how to use the second argument.
Report Abuse
evolvedpikachu is not online. evolvedpikachu
Joined: 18 Aug 2010
Total Posts: 10696
06 Apr 2013 11:26 PM
Oh hey looky I just figured the second argument out!
Report Abuse
evolvedpikachu is not online. evolvedpikachu
Joined: 18 Aug 2010
Total Posts: 10696
06 Apr 2013 11:39 PM
Now, how do I let the character move the camera around?
Report Abuse
KEVEKEV77 is not online. KEVEKEV77
Joined: 12 Mar 2009
Total Posts: 6961
30 Jun 2014 04:32 PM
set it back to custom
Report Abuse
12packkid is not online. 12packkid
Joined: 24 Jun 2011
Total Posts: 1418
03 Jul 2014 04:03 PM
@Kev, nice one for bumping an old thread. Great idea (not).
Report Abuse
AnonyAnonymous is not online. AnonyAnonymous
Joined: 23 Jun 2013
Total Posts: 6332
03 Jul 2014 04:05 PM
It's only been five days, additionally, he was giving the topic creator useful information.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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