|
| 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 |
|
|
|
| 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 |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 06 Apr 2013 11:06 PM |
| I said this wasn't the full script lol. |
|
|
| Report Abuse |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 06 Apr 2013 11:18 PM |
| I've considered Interpolate but a person said something about "jerky camera movements". |
|
|
| Report Abuse |
|
|
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 |
|
|
|
| 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 |
|
|
|
| 06 Apr 2013 11:26 PM |
| Oh hey looky I just figured the second argument out! |
|
|
| Report Abuse |
|
|
|
| 06 Apr 2013 11:39 PM |
| Now, how do I let the character move the camera around? |
|
|
| Report Abuse |
|
|
KEVEKEV77
|
  |
| Joined: 12 Mar 2009 |
| Total Posts: 6961 |
|
| |
|
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 |
|
|
|
| 03 Jul 2014 04:05 PM |
| It's only been five days, additionally, he was giving the topic creator useful information. |
|
|
| Report Abuse |
|
|