Jump to content

Scaling camera physics to enter rooms


Go to solution Solved by Dreikblack,

Recommended Posts

Posted

Hi,

I've attached FPSControllers script to a camera. I've scaled the camera to enter rooms in my map, but even if I set a very little scale size, it refuse to enter.

An idea ?

 

screenshot.png

Posted

I meant by pivot an Empty, in Misc because it is a name in code/engine

image.png.0e15b3613f3cfa0adf72fda4aefc2dd3.png

After attaching a controller to it you can change a fov in line "self.camera:SetFov(70)" to needed value.

Or add to FirstPersonControls.json a fov value like that:

{
    "component":
    {
        "properties":
        [
            {
                "name": "mousesmoothing",
                "label": "Mouse smoothing",
                "value": 0.0
            },
            {
                "name": "mouselookspeed",
                "label": "Look speed",
                "value": 1.0
            },
            {
                "name": "movespeed",
                "label": "Move speed",
                "value": 4.0
            },
			 {
                "name": "fov",
                "label": "FOV",
                "value": 70
            }
        ]
    }
}

And in FirstPersonControls.lua add "fov = 70" to other value at top and then change ""self.camera:SetFov(70)" to "self.camera:SetFov(self.fov)"

With you will be able to change a fov as component variable in the Editor

Posted

Made updateFov() because Start() is called with adding a component automatically.

Example use in main lua:

-- Get display list
local displays = GetDisplays()

-- Create a window
local window = CreateWindow("Ultra Engine", 0, 0, 1280, 720, displays[1], WINDOW_TITLEBAR | WINDOW_CENTER)

-- Create framebuffer
local framebuffer = CreateFramebuffer(window)

-- Create world
local world = CreateWorld()

-- Create light
local light = CreateDirectionalLight(world)
light:SetColor(2)
light:SetRotation(45, 35, 0)

-- Create ground
local ground = CreateBox(world, 10, 1, 10)
ground:SetPosition(0, -0.5, 0)
ground:SetColor(0,1,0)

local box = CreateBox(world, 1, 1, 1)
box:SetPosition(0, 0.5, 1)
box:SetColor(1,1,0)

-- Create model
local model = CreateCylinder(world, 1, 1, 5)
model:SetPosition(0, 3, 0)
model:SetRenderLayers(0)
local fpsController = model:AddComponent(FirstPersonControls)
fpsController.fov = 100
fpsController:updateFov()


while window:Closed() == false and window:KeyHit(KEY_ESCAPE) == false do
    world:Update()
    world:Render(framebuffer)
end

FirstPersonControls.zip

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

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...