0
$\begingroup$

To put it simply, I need something like the Copy Transform constraint that'll work for the BGE.

I have a setup for landscape Level of Detail, in which there are 2 scenes (one for high-poly models and one for low-poly models), each with a camera. The high-poly scene's camera has the low-poly scene set as a scene background. Look at this video for more info on my LoD method. The problem is I can't figure out a way to make the cameras in each scene move in exactly the same way while in-game to make the scenes line up correctly. If needed I can use Python scripts, but I don't know the language all too well. Thanks to anyone who helps in advance.

$\endgroup$

1 Answer 1

1
$\begingroup$

as I understood this script may help you.

from bge import logic

cnt = logic.getCurrentController()
scn = logic.getSceneList()[0] # the background scene or low-poly scene
cam1 = cnt.owner # the high-poly scene camera
cam2 = scn.objects['Low_poly_camera'] # the low-poly scene camera

def c2tc1(): # we set the cam2 pos/rot to the cam1
    cam2.worldPosition = cam1.worldPosition
    cam2.worldOrientation = cam1.worldOrientation

c2tc1()

How it works:

this code should run always with high-poly scene camera that moves, you don't need to move the low-poly scene camera it will follow the high camera always.

Make sure that:

True level triggering pulse mode is active so the code should run on each frame.

$\endgroup$
4
  • $\begingroup$ Thank you for your code. It does exactly what I wanted it to do, but there's a small problem. The cameras are slightly out of sync with one another, causing the background and foreground scenes to get out of alignment and reveal the seam where the 2 scenes meet. This is probably due to the time it takes for the code to run being longer than the length of 1 frame, making the lag noticeable. If there's any way that this code could be optimized or a faster way could be explained here, that would be appreciated! $\endgroup$ Jan 12, 2018 at 3:15
  • 1
    $\begingroup$ you need to set logic rate to high value to avoid this here is an updated code from bge import logic import GameLogic GameLogic.setLogicTicRate(1024) cnt = logic.getCurrentController() scn = logic.getSceneList()[0] cam1 = cnt.owner cam2 = scn.objects['Low_poly_camera'] def c2tc1(): cam2.worldPosition = cam1.worldPosition cam2.worldOrientation = cam1.worldOrientation c2tc1() $\endgroup$
    – Fred
    Jan 12, 2018 at 18:22
  • $\begingroup$ Your code works, but while it solves the problem of the cameras being out of sync by increasing the game logic ticks per second, it speeds up all of the OTHER game logic, making everything in my game that relies on logic bricks (so pretty much everything) go WAY faster than they should, and if I lower the tick rate to get my logic back to the correct speed, the background gets out of sync again. Any ideas? (ALSO changing the tick rate changes the game FPS to 60 from 30, which I changed for performance reasons.) $\endgroup$ Jan 12, 2018 at 23:29
  • $\begingroup$ you need to use small values such as motion actuator location offset make it smaller and it will work correctly! $\endgroup$
    – Fred
    Jan 12, 2018 at 23:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .