Skip to content
nikki93 edited this page Sep 13, 2010 · 3 revisions

Handles the Camera (the ‘viewpoint’ from which the scene is viewed). The CameraHandler has 6 ‘modes’:-

0: None – Do nothing.
1: Look At – Sit in one place, and look at the target object.
2: Third Person – ‘Follow’ the object, looking at it from behind.
3: Spline – Move along a spline, looking at the target object.
4: Lose – Do the ‘lose’ animation.
5: Win – Do the ‘win’ animation.

Usually you don’t go into modes 4 and 5 yourself (they’re meant for when the Player loses or wins, and are enabled automatically). The ‘target object’ can be set using the ‘setTarget’ Python function. If you want to set the Player as the target, use the ‘targetPlayer’ function instead (if you target the Player directly, the Camera rolls around along with him :P ).

Here’s an example script for the CameraHandler that defines a spline through Point objects (which you can create and position in Blender) with names ‘cameraTarget1’, ‘cameraTarget2’, …, ‘cameraTarget5’:-

def create(self):
    self.beginSpline(splineTime)
    self.addSplinePoint(0, self.getPosition())
    self.addSplinePoint(0.75, Ngf.getObject("camTarget1").getPosition())
    self.addSplinePoint(1.5, Ngf.getObject("camTarget2").getPosition())
    self.addSplinePoint(2, Ngf.getObject("camTarget3").getPosition())
    self.addSplinePoint(2.8, Ngf.getObject("camTarget4").getPosition())
    self.addSplinePoint(3.8, Ngf.getObject("camTarget5").getPosition())
    self.endSpline()

    self.p_currState = 3

Properties

(none)

Python Events

(none)

Python Properties

p_currState
The current mode (0, 1 etc.).

p_movementFactor
The speed with which the Camera tries to move to it’s required position (lower for smoother movements). Default: 4.

p_rotationFactor
The speed with which the Camera tries to rotate to it’s required orientation (higher for smoother rotations). Default: 0.

Python Methods

setTarget(target)
Target the given object.

targetPlayer()
Target the player.

beginSpline(time)
Begin defining a spline with the given length in seconds.

addSplinePoint(time, position)
Add a spline point with the given position, to be reached at the given time. ‘time’ is in seconds elapsed since starting the spline animation.

endSpline()
End defining the spline.

Clone this wiki locally