I just added support for adding custom camera modes, will be available in the next update (0.5.4.1) This is an example of how to integrate your own camera mode into the game. It'll look like this: 1. Make sure you have Advanced mode activated 3. Create a new file in folder lua/ge/extensions/core/cameraModes/ The filename will be the new mode's name. Keep it simple, no spaces or anything special. example: topDown.lua : Code: -- This Source Code Form is subject to the terms of the bCDDL, v. 1.1. -- If a copy of the bCDDL was not distributed with this -- file, You can obtain one at http://beamng.com/bCDDL-1.1.txt --- This is an example of a custom camera mode :D local C = {} C.__index = C function C:init() --- when this is loaded, the config will be in self alread. I suggest to inspect it: -- dump(self) self.veloSmoother = newExponentialSmoothing(20, 1) self.lastDataPos = vec3() self.fov = self.fov or 20 --- this marks it as base mode. It needs to set position, rotation and fov correctly self.baseMode = true -- add it to the default camera modes? self.register = true end function C:update(data) -- get the data local ref = vec3(data.veh:getNodePosition(self.refNodes.ref)) local back = vec3(data.veh:getNodePosition(self.refNodes.back)) -- we need to manually smooth the velocity as its too spiky otherwise which results in bad camera movement local velo = self.veloSmoother:get((self.lastDataPos - data.pos):length()) self.lastDataPos = data.pos -- figure out the way the vehicle is oriented local dir = (ref - back):normalized() -- find out the target that we should look on local targetPos = data.pos + vec3(dir.x, dir.y, 0) * math.min(50, 70 * velo) -- and place the camera above it local camPos = targetPos + vec3(0, 0, (velo * 80) + 50) -- then look from camera position to target :) local qdir = quatFromDir((targetPos - camPos):normalized()) -- set the data, this needs to happen data.res.pos = camPos -- required, vec3() data.res.rot = qdir -- required, quat() data.res.fov = self.fov -- required data.res.targetPos = targetPos -- this is optional return true end -- DO NOT CHANGE CLASS IMPLEMENTATION BELOW return function(...) local o = ... or {} setmetatable(o, C) o:init() return o end 3. Reload GameEngine Lua to reload the mode on the fly: CTRL+L And done, cycle through the modes with 'C' 4. Pack the mod as .zip with the full path inside the zip (see attachment to this post). Then it can be just placed inside the mods/ folder to work Even if the update is not out yet, wanted to post already so you can have a look
This is really great, should allow for some great shots! However, how do we define the cameras position in relation to the vehicle?
When are the functions C:reset and C:reload called? Also, where does the data for C:setFOV and C:setOffset come from (what does the player do to change these)?
reset - whenever the camera is resetted reloaded - whenever the module is being reloaded completely - so when the vehicle is reloaded. setFov, setOffset: from the jbeam: fov and offset of the camera's n/b section
Do any of you happen to know how to have the vehicle camera spawn in at Default Orbit position after each respawn? It stopped automatically resetting for me after I respawn a vehicle, and it becomes annoying having to always manually reset the camera after moving it around before the vehicle was reset. I've searched all over Google and none of the Keypad Numbers work for me, they just serve as another driving pad. For example, if I set it manually after driving for a bit and keeping it facing the default direction, If I we're to respawn my vehicle, the camera would be facing the front. Basically the camera flips 180 degrees after each respawn, based on the previous camera position before respawning. *No I have not changed any of my controls, they are default.
Pressing the "Num" button in the upper three button row of the keyboard should fix that, you've probaby hit it accidentally and turned the number keys of that way .
This doesn't seem to be working. For clarification, this function should be called when the vehicle is reset (pressing "r") or reloaded ("ctrl+r")?
Which number do I press to reset the camera? I'm looking for a way to have it automatically reset after each respawn anyways...