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: Camera Tweening

Previous Thread :: Next Thread 
thelolguy301 is not online. thelolguy301
Joined: 27 Sep 2011
Total Posts: 2997
19 Jan 2016 12:21 AM
I want to make a script that makes the camera of the player slowly tween to a specified coordinate. For example, there is a part in workspace called PointOfView and I want the camera to tween to that part's CFRame.

Could anyone show me how this is done and how it works?
Report Abuse
FPSPwnz0r is not online. FPSPwnz0r
Joined: 27 Jun 2011
Total Posts: 2737
19 Jan 2016 01:31 AM
DoogleFox has an open source camera panner thingy in his places that could help you


idk though


Report Abuse
AdvancedObjects is not online. AdvancedObjects
Joined: 11 Dec 2012
Total Posts: 3354
19 Jan 2016 01:42 AM
Interplation.



#Code print("Song Link: http://www.roblox.com/Deorro-vs-Swedish-House-Mafia-Save-The-5-Hours-item?id=340827217")
Report Abuse
AdvancedObjects is not online. AdvancedObjects
Joined: 11 Dec 2012
Total Posts: 3354
19 Jan 2016 01:43 AM
Interpolation* is basically camera tweening



#Code print("Song Link: http://www.roblox.com/Deorro-vs-Swedish-House-Mafia-Save-The-5-Hours-item?id=340827217")
Report Abuse
thelolguy301 is not online. thelolguy301
Joined: 27 Sep 2011
Total Posts: 2997
19 Jan 2016 03:41 AM
There is an API :Interpolate(endpos,endfocus,duration) for Camera, but it doesn't seem to work very well. All it does is it moves towards the part, and then the screen completely goes white.
Report Abuse
0supadude0 is not online. 0supadude0
Joined: 11 Aug 2010
Total Posts: 649
19 Jan 2016 07:08 AM
Your screen goes white (normally) because you're setting endpos and endfocus to the same value.
The camera interpolate method seems a little odd anyway since it floats to the end position then suddenly 'snaps' to face the end focus at the last second. So an alternative to the camera interpolate method could just be to manually interpolate it with the cframe lerp method:
http://wiki.roblox.com/index.php?title=CFrame
Report Abuse
thelolguy301 is not online. thelolguy301
Joined: 27 Sep 2011
Total Posts: 2997
19 Jan 2016 07:25 AM
I never did the lerp before. How would this work?
Report Abuse
0supadude0 is not online. 0supadude0
Joined: 11 Aug 2010
Total Posts: 649
19 Jan 2016 07:47 AM
lerp needs your initial and final cframe value, plus a number between 0 and 1 to dictate the 'progression' from the initial cframe to the second (wiki can explain this far better than me).
So you'll want to lerp both your coordinateframe and your focus simultaneously, something like this;

local duration = 1
local elapsed = 0
repeat
local dt = game:GetService("RunService").RenderStepped:wait()
elapsed = math.min(elapsed+dt,duration)
camera.CoordinateFrame = original:lerp(final,elapsed/duration)
until elapsed >= duration
Report Abuse
joshuarome is not online. joshuarome
Joined: 29 Aug 2008
Total Posts: 135
19 Jan 2016 09:39 AM
Just editing what was put above by 0supadude, as there is ways of making the code he posted alot more efficent

local function Tween(Weld,Goal,Time)
local Start = tick()
local a = 0

repeat
local Percent = min(1,(tick()-Start)/Time)
a = a+(Percent-a)*.25
Weld = lerp(Initial,Goal,a)
stepped:wait()
until a == 1
end

In this context weld would be camera, so you run:
Tween(camera.CoordinateFrame,goal,time) time is the length in seconds
Report Abuse
joshuarome is not online. joshuarome
Joined: 29 Aug 2008
Total Posts: 135
19 Jan 2016 09:48 AM
oops forgot to add:

local cf = CFrame.new

local function lerp(a,b,d)
return a:lerp(b,d)
end
Report Abuse
0supadude0 is not online. 0supadude0
Joined: 11 Aug 2010
Total Posts: 649
19 Jan 2016 07:55 PM
How is that more efficient?

Not being snarky, genuinely asking
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