Jump to content
omid3098

Control camera FOV with keys [LE2] [Solved]

Recommended Posts

Hi. I am trying to control camera FOV using two keys in Lua (to increase and decrese) but I cant access to main Camera FOV.

 

I have a CameraManager node in the scene and the code is something like this:

 

require("Scripts/class")
require("Scripts/constants/keycodes")
require("Scripts/hooks")

local class=CreateClass(...)

function class:CreateObject(model)
function object:DHook()
if KeyDown(KEY_U)==1 then
CameraZoom(45.0) -- or what? how should I use CameraZoom? 
end
end
AddHook("Flip" , object.DHook )
function object:Free()
RemoveHook("Flip" , object.DHook )
self.super:Free()
end
end

 

there were CameraZoom(cam,value) in the forum but I dont know what is cam or how I can create that to use Camera zoom. actually tried cam=fw.main.camera but that is for framework I think.

 

I did not write other parts of this code and also I don't have access to our programmer.

and I'm not dump smile.png

thanks before

Share this post


Link to post

Ok. I'm a dump.

would you please describe more?

CameraZoom is only for C and C++ and there is nothing for LUA.

 

I just have to open Editor and edit some LUA codes to play with camera and do some trailer.

 

 

Edit: this code gives "Malformed number near 0.5f" error.

CameraZoom(camera, 0.5f)

Edited by omid3098

Share this post


Link to post

You do not need to include the 'f' in the float value.

Share this post


Link to post

Your programmer is going to have to do this. I can't debug a program with one line of code.

Share this post


Link to post

Programmer is doing bugfix since more than 2 months and I don't have permission to access him.

 

this is my CameraManager.lua:

require("Scripts/class")
require("Scripts/constants/keycodes")
require("Scripts/hooks")
local class=CreateClass(...)
function class:CreateObject(model)
local object=self.super:CreateObject(model)
--object.cameraFOV = CameraZoom(camera,1.0)
SetFarDOFRange(2,5)
SetFarDOFStrength(1)
SetFarDOF(1)
function object:DHook()
 -- Test if keys are working
 if KeyDown(KEY_U)==1 then
  SetFarDOF(1)
 end
 if KeyDown(KEY_Y)==1 then
  SetFarDOF(0)
 end
end
AddHook("Flip" , object.DHook )
function object:Free()
 RemoveHook("Flip" , object.DHook )
 self.super:Free()
end
end

 

I can enable/Disable DOF with keys but I have no Ideas how to access camera FOV.

Share this post


Link to post

now it works using this code:

require("Scripts/class")
require("Scripts/constants/keycodes")
require("Scripts/hooks")
local class=CreateClass(...)
function class:CreateObject(model)
local object=self.super:CreateObject(model)
function object:Update()
 if KeyDown(KEY_UP)==1 then
  CameraZoom(fw.main.camera,0.5)
 end
 if KeyDown(KEY_DOWN)==1 then
  CameraZoom(fw.main.camera,1.0)
 end
end
function object:Free()
 self.super:Free()
end
end

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...