I need help with a camera that suddenly warps with the character seemlesly[SOLVED]

Could someone elaborate on which script and line that this belongs to fix this problem?

bge.logic.getCurrentScene().currentCamera.timeOffset = 0.0. its
called ‘slow parent’.

If I know what to do, I can do it myself now by looking at the console.
I’ve managed to figure a lot out recently so, I am getting pretty good.
I added Cotacks’ teleportation project to this project and assigned different teleport locations where one can go and the other can’t.
It’s a genius script!

http://www.mediafire.com/file/8k3xoz4azpmrr32/cineCam_Teleport_new_room.rar/file

I just need the camera to not slide smoothly to the destination.
'smove' in cineCam.py in the gryCine folder but, it affects the main camera when I only want a “jump cut” for teleportation and not the rest of the camera angles.

Straight-forward specific answers would be nice.
Thank you!

I’m not sure what the teleportation project is but in my portal functions, i turn off camera slow parent(set to 0.0) right before the move and then set it back immediately after:

...
cam_offset_previous = obj.cam_player.timeOffset
obj.cam_player.timeOffset = 0.0
obj.worldPosition = self.gate_target.worldPosition + delta  # Move the object to the destination
obj.cam_player.timeOffset = cam_offset_previous
...

This works if your teleportation routine is instantaneous, ie. setting worldPosition. If it’s queued or something else then it should still work as long as you wrap whatever code that does the moving in the slow parent disable/reenable code.

So, I put this in cineCam.py but, what line though.
I’m terrible with programming but, I’m slowly learning.

1. import gryLib as gry
2. class CineamaticCamera(gry.BaseClass):
3.   """
4.   a cineamatic camera
5.   """
6.   from gryLib import child
7.   child
8.   
9.   def __init__(cam, DNU, sheet=None):
10.     """
11.     cam.get('smove', 0): the amout of camera smothing
12.     cam.child('Cam'):  the camera object
13.     cam.child('Focus'):  the object the camera looks at
14.     """
15.     gry.BaseClass.__init__(cam, DNU, sheet)
16.     cam.cam = cam.child('Cam')
17.     cam.focus = cam.child('Focus')
18.     #:  the focus needs its own independant position, but its convenyent to stor it as a child
19.     cam.focus.removeParent
20.     cam.target = None
21.     cam.offset = cam.get('offset', 0)
22.     
23.     #:  tell everyone that your the current camera
24.     gry.msgr.say('currentCamera', [cam], 'currentCamera')
25.     #:  this alows you to easly set or disable the game camera
26.     #:  theres an object that represents the camera on an inactive layer
27.     #:  this alows you to see what the camera is doing from out side of the camera
28.     if cam.get('setAsMain', False):
29.       cam.scene.active_camera = cam.cam
30.     
31.     #:  set veryious defaults for the camera
32.     cam.smove = cam.get('smove', 0)
33.     
34.     cam.pivotType = None
35.     cam.pivot = None
36.     cam.focusOffset = 1
37.     cam.camOffset = 3 # this raises up the focus of the camera so your not looking at the chars feet
38.     cam.dist = 20
39.     cam.minDist = 10

40. #found a little spot here but, don't know what to do next and this might be wrong

41.   
42.   
43.   
44.   def message(self, subject, args, filter, to, fromm):
45.     """
46.     currentChar
47.     :cameraPost
48.     if args[0] is the cameras target then it sets itself with
49.     self.pivot, self.pivotType, self.dist, self.offset, self.lens = args[1:]
50.     """
51.     #:  the camera will point at the current char
52.     if subject == 'currentChar':  self.target = args[0]
53.     #:  set the cameras stats from a cameraPost event
54.     if subject == 'cameraPost':
55.       if self.target == args[0]:
56.         self.pivot, self.pivotType, self.dist, self.offset, self.lens = args[1:]
57.   
58.   
59.   def run(cam):
60.     """
61.     updates the position of the camera
62.     """
63.     if not cam.target:  return
64.     #;  the focus is what the camera looks at
65.     #:  the center of objects are often place at the bottom of the object,
66.     #:  therefore it can be usefull to bring the focus up a little so your looking at the targets eyes rather then its feet
67.     cam.focus.worldPosition = cam.target.worldPosition
68.     cam.focus.worldPosition.z += cam.offset

69.     #:  follow the char from the angle of the pivot
70.     if cam.pivotType == 'pan':
71.       cam.worldPosition = cam.focus.worldPosition
72.       
73.       #:  this gets the direction the pivot is pointing
74.       #:  single arrow emptys point to positive z,
75.       #:  so the angle has to be fudged
76.       vec = cam.pivot.getAxisVect([0, 0, 1])
77.       #:  the magnatude of the vector is how long it is
78.       vec.magnitude = cam.dist
79.       #:  you can imagine there being an arrow pointing from the focus to were we want the camera
80.       #:  we send the camera down that arrow
81.       cam.worldPosition -= vec
82.       #:  this causes the camera to look either up or down on at the focus
83.       cam.worldPosition.z += cam.camOffset


84.     #:  rotate around the pivot keeping the same distance
85.     #:  the focus is always betwene the camera and the pivot
86.     elif cam.pivotType == 'orbit':
87.       cam.worldPosition = cam.focus.worldPosition
88.       
89.       #:  this is hard to explane.  you may want to draw it
90.       #:  draw a line A from the pivot to the target
91.       #:  draw a line B from the target to were we want the camera
92.       #:  draw a line C from the pivot to the were we want the camera
93.       #:  A and B should have the same angle,
94.       #;  so we set B's angle to A's
95.       #:  A + B should have the same distance as C
96.       #:  so we set the distance of B to the distance of C - A
97.       #:  now B gives us the position of the camera relitive to the position of the target
98.       #:  this alows us to ensure that the camera is not too close to the target
99.       #:  its posible that there may be an easer way to do this
100.       
101.       #:  get the position of the target
102.       vec = cam.target.worldPosition.copy()
103.       #:  move the vector so its the same hight as the pivot,
104.       #:  but dont change the hight of the char
105.       vec.z = cam.pivot.worldPosition.z
106.       import mathutils # currently the rotation on an orbit has to be 0.  hopfully this wont mess anything up
107.       cam.pivot.worldOrientation = mathutils.Euler((0, 0, 0))
108.       #:  get the distance and local vector from the pivot to the target
109.       dist, wVec, lVec = cam.pivot.getVectTo(vec)
110.       
111.       #:  find the distance from the target to the camera
112.       dist = cam.dist - dist
113.       dist = gry.minmax(dist, cam.minDist, cam.dist)
114.       lVec.magnitude = dist
115.       #:  the cameras position was set to the target,
116.       #:  so if we add the local vector it gooes to the were we want the camera
117.       cam.worldPosition += lVec
118.       cam.worldPosition.z += cam.camOffset


119.   
120.     elif cam.pivotType == 'static':
121.       #: put the camera on the static pivot
122.       cam.worldPosition = cam.pivot.worldPosition
123.   
124.   
125.   
126.   
127.   
128.   @property # lower is faster.  0.0 to disable.
129.   def smove(cam):  return cam.cam.timeOffset
130.   @smove.setter
131.   def smove(cam, value):  cam.cam.timeOffset = value
132.   
133.   @property
134.   def lens(cam):  return cam.cam.lens
135.   @lens.setter
136.   def lens(cam, value):  cam.cam.lens = value

You need to set the time offset to 0.0 right before the teleportation. That looks to be in either teleport.py or tport.py. Then set it back immediately after the teleportation.

You could do it blunt force as in your first post with something like:
(inserting into teleport.py)

camera_original_offset = bge.logic.getCurrentScene().currentCamera.timeOffset
bge.logic.getCurrentScene().currentCamera.timeOffset = 0.0
#teleport the object to the coordinates
collision.hitObject.worldPosition = position # originally line 40
bge.logic.getCurrentScene().currentCamera.timeOffset = camera_original_offset

Or call the smove method on the camera object as the script intended but i couldn’t get the simulation to run properly so that may be up to you to discover.

The script is teleport.py and it’s being used in .blend and the the folder.
Couldn’t figure out how to get it to work on module.
so, I put a timeOffset game object or what?
I need specifics because, I’m still new to all this.

Error: sub(CineCam), Python script error
Traceback (most recent call last):
  File "F:\...\...\...\Blender Projects\cineCam ...\gryLib\main.py", line 33, in sub
    else:  return clss(obj, *args, **kwargs)
  File "F:\...\...\...\Blender Projects\cineCam ...\gryCine\cineCam.py", line 37, in __init__
    camera_original_offset = bge.logic.getCurrentScene().currentCamera.timeOffset
NameError: name 'bge' is not defined

Specifically, you need to alter the teleport.py file, not cineCam.py. remove what you added to cineCam.py and add these two lines to teleport.py right before the line that does the teleportation(line 39 in the blend you provided):

camera_original_offset = bge.logic.getCurrentScene().currentCamera.timeOffset
bge.logic.getCurrentScene().currentCamera.timeOffset = 0.0

make sure your indentions match those in the file. it needs to be indented the same amount as the teleportation line. after that teleportation line, add this:

bge.logic.getCurrentScene().currentCamera.timeOffset = camera_original_offset

so now the bottom of the teleport.py file should look like:


     camera_original_offset = bge.logic.getCurrentScene().currentCamera.timeOffset
     bge.logic.getCurrentScene().currentCamera.timeOffset = 0.0
     #teleport the object to the coordinates
     collision.hitObject.worldPosition = position
     bge.logic.getCurrentScene().currentCamera.timeOffset = camera_original_offset

crashes as soon as I hit the teleporter.

Error: Python(t_start), Python script error
Traceback (most recent call last):
File “teleport.py”, line 37, in
AttributeError: ‘KX_Scene’ object has no attribute ‘currentCamera’

lol sorry wasn’t paying attention to that bit. change “.currentCamera” in the three lines to “.active_camera”

don’t put the quotation marks in

     camera_original_offset = bge.logic.getCurrentScene().active_camera.timeOffset
     bge.logic.getCurrentScene().active_camera.timeOffset = 0.0
     #teleport the object to the coordinates
     collision.hitObject.worldPosition = position
     bge.logic.getCurrentScene().active_camera.timeOffset = camera_original_offset

Do I add any special game properties and to which object?
Still not working.
Do I set a special game property to the teleporter or the cineCam object?

What isn’t working? Error message?

You shouldn’t need to set any special properties as this will just affect the active camera in the scene directly and turn off slow parent immediately before teleporting your player and then turn it back on immediately after.

By the way, how are you running this? When I press ‘P’ in blender, all i see are some wooden boxes in bottom right. If i run in standalone player it crashes immediately with

Traceback (most recent call last):
File "/home/bryan/Downloads/cineCam Cataclysm game template/gryLib/main.py", line 33, in sub
  else:  return clss(obj, *args, **kwargs)
File "/home/bryan/Downloads/cineCam Cataclysm game template/gryCine/cineCam.py", line 24, in __init__
  gry.msgr.say('currentCamera', [cam], 'currentCamera')
File "/home/bryan/Downloads/cineCam Cataclysm game template/gryLib/tools/Messager.py", line 86, in say
  bge.logic.sendMessage(filter, body, to, fromm)
TypeError: sendMessage() argument 4 must be str, not None

Do you have a working demo of this? Are you running it in anything other than the latest Blender?

https://www.mediafire.com/file/mna148oflh7fa1d/cineCam_Teleport_new_room.rar/file

the code looks fine. i still can’t get it do anything other than sit there or error out from sendMessage() so i can’t test it.

what blender version are you using?
standalone or embedded player?
what controls do what?

Oh right! I should have put Upbge in the post.
Oops!

maybe upbge accesses the camera differently. guess you’ll need someone familiar with it to help you out. sorry

Well, thanks for trying!

128.   @property # lower is faster.  0.0 to disable.
129.   def smove(cam):  return cam.cam.timeOffset
130.   @smove.setter
131.   def smove(cam, value):  cam.cam.timeOffset = value

Redundant. These attributes can be accessed directly from the object reference.
It’s one line: camera.timeOffset = value

So I’d say forget about this method.

Grab a reference to the main camera. camera = bge.logic.getCurrentScene().active_camera
when you need the camera to snap, camera.timeOffset = 0.0
move the camera’s target to the intended position,
then restore the previous value for timeOffset.

thing is some rooms I want a gradual transition with smove.
However rooms you teleport to I want the camera to snap there.

if portal["bool_property"]:
    #make camera snap

EDIT: also, smove only sets timeOffset. It’s the exact same as using camera.timeOffset.

I didn’t write the code so I need to know specifically how to set it up exactly (lines, specific objects and game properties)

Aye, that seems to be the problem.

Your blend crashes way too much. Give me something that isn’t corrupted and I’ll see about it.