• Smooth camera
    10 replies, posted
Is their anyway to make smooth camera movements for a, 'introduction' for example?
CalcView + math.Approach()
Thanks a bunch, how can I smooth the increase, can FrameTime do something?
You could use LerpVector and LerpAngles for smoother movement
Example code? I'm not sure how to apply this Thanks for the quick reply's
[lua]local oldVector = Vector(100,100,100); local targetVector = Vector(0,0,0); local function myhook() oldVector = LerpVector(0.20,oldVector,targetVector); print(oldVector); end myhook(); myhook(); myhook(); myhook(); myhook(); myhook(); myhook(); myhook(); myhook(); myhook(); myhook(); myhook(); myhook(); [/lua] This should demonstrate it. Everytime myhook() runs oldVector will get closer to targetVector "smoothy".
[QUOTE=_NewBee;34911838][lua]local oldVector = Vector(100,100,100); local targetVector = Vector(0,0,0); local function myhook() LerpVector(0.20,oldVector,targetVector); print(oldVector); end myhook(); myhook(); myhook(); myhook(); myhook(); myhook(); myhook(); myhook(); myhook(); myhook(); myhook(); myhook(); myhook(); [/lua] This should demonstrate it. Everytime myhook() runs oldVector will get closer to targetVector "smoothy".[/QUOTE] won't this be better? [lua] local CurV = Vector(100,100,100) local Target = Vector(0,0,0) function Myhook() CurV = LerpVector(0.20,CurV,Target) end [/lua]
They are basically the same except mine prints the results in console so you can see what the function actually does. Oh, and just a tip, there's no point in making the function global and you normally start function names with a lowercase letter, then use capitals when new worlds comes. Same goes for variables.
Dingusnin has set it so that, every time the function is called, it sets CurV to a LerpVector of itself. All you were doing in your function was calling the same math over and over, while changing or updating nothing.
[QUOTE=_NewBee;34913485] Oh, and just a tip, there's no point in making the function global and you normally start function names with a lowercase letter, then use capitals when new worlds comes. Same goes for variables.[/QUOTE] I think the naming of your functions and variables depends on your coding style. There's no right or wrong way...
It will pays off to have the habit when you ever want to try another more complicated language.
Sorry, you need to Log In to post a reply to this thread.