Aurarus
|
  |
| Joined: 22 Dec 2008 |
| Total Posts: 4761 |
|
|
| 02 Jan 2013 07:03 AM |
I have an iterator,
i = 1,15
And in it, I want to make the FOV of the player's camera slide to 80.
I had something along the lines of:
game.Workspace.CurrentCamera.FieldOfView = 70 + i
... But it gives 5 annoying error-ish messages in the output, because you can't have the FOV go over 80.
How would I make it turn from 70 to 80 with an iterator of 15?
I think I'm overthinking it, while it's some simple division with i... |
|
|
| Report Abuse |
|
|
Aurarus
|
  |
| Joined: 22 Dec 2008 |
| Total Posts: 4761 |
|
|
| 02 Jan 2013 07:03 AM |
| ... Without it going 80. That's a key part. |
|
|
| Report Abuse |
|
|
Aurarus
|
  |
| Joined: 22 Dec 2008 |
| Total Posts: 4761 |
|
|
| 02 Jan 2013 07:04 AM |
| Without it going over 80.* Gosh, I'm derpy today. D: |
|
|
| Report Abuse |
|
|
|
| 02 Jan 2013 07:09 AM |
It would be easy if you either didnt care about the amount of iterations or if you didnt care about the time.
Cuz you could just iterate towards desired fov, increasing the fov with larger amount each time
or you could do it in fixed steps, but on each iteration wait less time |
|
|
| Report Abuse |
|
|
Aurarus
|
  |
| Joined: 22 Dec 2008 |
| Total Posts: 4761 |
|
|
| 02 Jan 2013 07:09 AM |
I think I figured it out.
for i = 1, 15 game.Workspace.CurrentCamera.FieldOfView = 70 + (i*(10/15))
But how would I make it find out how much the last number in the iterator is?
Like, say if I changed the for i = 1, x
Then I want this segment: 70 + (i*(10/x)) <-- Like that
|
|
|
| Report Abuse |
|
|
|
| 02 Jan 2013 07:28 AM |
idk
i was thinking of just clamping the fov so that it wont get larger than what you want it to end up as, and when it reaches that just break out of the loop (use while/repeat until loop instead?)
though im sure there is some fancy math that lets you set the start and end fov, amount of iterations and acceleration... (you actually just need to go from 0 to 1 in x iterations with y acceleration) |
|
|
| Report Abuse |
|
|
Aurarus
|
  |
| Joined: 22 Dec 2008 |
| Total Posts: 4761 |
|
|
| 02 Jan 2013 07:43 AM |
And how do I make multiple functions run at once?
I thought if I make another function and run it inside another script, the script wouldn't wait for that function to finish to move on.
Apparently that's not that case. :\ |
|
|
| Report Abuse |
|
|
|
| 02 Jan 2013 07:45 AM |
you can use Spawn(func) (or was it spawn(func))
or delay(time,func) |
|
|
| Report Abuse |
|
|
Aurarus
|
  |
| Joined: 22 Dec 2008 |
| Total Posts: 4761 |
|
|
| 02 Jan 2013 08:06 AM |
There are some variables I don't want to keep redefining. Is it possible to write out functions within other functions, using variables which are in the "parent" function? |
|
|
| Report Abuse |
|
|
|
| 02 Jan 2013 08:15 AM |
for i = 0, 1, 0.1 do camera.FOV = i*10+70 end |
|
|
| Report Abuse |
|
|
Aurarus
|
  |
| Joined: 22 Dec 2008 |
| Total Posts: 4761 |
|
|
| 02 Jan 2013 08:16 AM |
@ Brandon,
The idea was that I could only work with i = 1, 15.
There's more to the script. |
|
|
| Report Abuse |
|
|
SN0X
|
  |
| Joined: 24 Oct 2011 |
| Total Posts: 7277 |
|
|
| 02 Jan 2013 08:21 AM |
while Workspace.CurrentCamera.FieldOfView < 80 do Workspace.CurrentCamera.FieldOfView = Workspace.CurrentCamera.FieldOfView + SOMENUMBERHERE wait(SOMENUMBERHERE) end workspace.CurrentCamera.FieldOfView = 80 -- TO PREVENT GOING OVER 80, OK?
GO TO SCRIPTING HELPERS NEXT TIME
KTHX |
|
|
| Report Abuse |
|
|
SN0X
|
  |
| Joined: 24 Oct 2011 |
| Total Posts: 7277 |
|
|
| 02 Jan 2013 08:22 AM |
>The idea was that I could only work with i = 1, 15.
lolno we're not helping you on your LuaLearners exam. |
|
|
| Report Abuse |
|
|
Aurarus
|
  |
| Joined: 22 Dec 2008 |
| Total Posts: 4761 |
|
|
| 02 Jan 2013 08:36 AM |
LuaLearners exam?
What on earth are you talking about?
By the way, your "solution" to my question was garbage. I was asking for the math that'd make 15 changes between 70 and 80. An if statement only stops the annoying error message. |
|
|
| Report Abuse |
|
|
booing
|
  |
| Joined: 04 May 2009 |
| Total Posts: 6594 |
|
|
| 02 Jan 2013 09:30 AM |
Wile troo doo Gt.fov.increaseumtil80() End da doo End End End |
|
|
| Report Abuse |
|
|
|
| 02 Jan 2013 10:22 AM |
Trai dis.
local Cam = workspace.CurrentCamera local CurrentFOV = Cam.FieldOfView local DesiredFOV = 80 local Step = 15 for i = 1,Step do Cam.FieldOfView = CurrentFOV+(DesiredFOV-CurrentFOV)*(i/Step) -- I think that is correct math. end |
|
|
| Report Abuse |
|
|
Aqualogy
|
  |
| Joined: 01 Dec 2012 |
| Total Posts: 226 |
|
|
| 02 Jan 2013 12:59 PM |
You can try a different method. Here's a different method you can try.
local Cam = workspace.CurrentCamera local CurrentFOV = Cam.FieldOfView local DesiredFOV = 80 local Difference = DesiredFOV - CurrentFOV
for x = 1, (math.pi/2) , (1/30) do wait(1/30) y = math.sin(x) Cam.FieldOfView = CurrentFOV + (Difference * y) end Cam.FieldOfView = CurrentFOV + (Difference * 1)
I haven't tested that so there may be some errors. |
|
|
| Report Abuse |
|
|
zars15
|
  |
| Joined: 10 Nov 2008 |
| Total Posts: 9999 |
|
|
| 02 Jan 2013 01:06 PM |
Just use some easy repeat skillz:
repeat game.Workspace.CurrentCamera.FieldOfView = 70 + i until game.Workspace.CurrentCamera.FieldOfView + i >= 80 game.Workspace.CurrentCamera.FieldOfView = 80 |
|
|
| Report Abuse |
|
|
|
| 02 Jan 2013 01:08 PM |
| Lol. I forgot to add a wait. :/ |
|
|
| Report Abuse |
|
|
zars15
|
  |
| Joined: 10 Nov 2008 |
| Total Posts: 9999 |
|
| |
|
zars15
|
  |
| Joined: 10 Nov 2008 |
| Total Posts: 9999 |
|
|
| 02 Jan 2013 01:12 PM |
repeat game.Workspace.CurrentCamera.FieldOfView = 70 + i wait(0.02) until game.Workspace.CurrentCamera.FieldOfView + i >= 80 game.Workspace.CurrentCamera.FieldOfView = 80 |
|
|
| Report Abuse |
|
|
|
| 02 Jan 2013 01:13 PM |
@Aqualogy
Your math is wrong. It doesn't start at the CurrentFOV, it just goes straight to 70, then goes to 80. |
|
|
| Report Abuse |
|
|
Aqualogy
|
  |
| Joined: 01 Dec 2012 |
| Total Posts: 226 |
|
|
| 02 Jan 2013 01:14 PM |
Using math.sin() correctly gives you a smooth transition.
(My method is above) |
|
|
| Report Abuse |
|
|
Aqualogy
|
  |
| Joined: 01 Dec 2012 |
| Total Posts: 226 |
|
|
| 02 Jan 2013 01:18 PM |
@kirky
I'm a bit confused. My method takes the current FOV and smoothly sets it to the desired FOV. It was not mean't to start at 70, but rather the FOV that the camera currently has.
If you see an error could you explain it more in depth? |
|
|
| Report Abuse |
|
|
|
| 02 Jan 2013 01:20 PM |
Oops, I messed up. You have to start at 0 for it to work right.
local Cam = workspace.CurrentCamera local CurrentFOV = Cam.FieldOfView local DesiredFOV = 20 local Step = 15 local Increment = 0.1 local Wait = 0.01 for i = 0,Step,Increment do -- See, start at 0. Cam.FieldOfView = CurrentFOV+(DesiredFOV-CurrentFOV)*(i/Step) -- I think that is correct math. print(Cam.FieldOfView) wait(Wait) end
|
|
|
| Report Abuse |
|
|