Put camera behind player.

Blitz3D Forums/Blitz3D Programming/Put camera behind player.

Farflame(Posted 2004) [#1]
I'm sure it's been asked a million times but I can't find a thread. Can someone tell me - or point me to a thread which explains it - how to position my camera directly behind my player so that it follows the players movement?


sswift(Posted 2004) [#2]
; Transform a point behind and above the player, in player space, to global space.
TFormPoint 0, 5, -5, Player, 0

; Position the camera at this global location.
PositionEntity Camera, TFormedX(), TFormedY(), TFormedZ()

; Point the camera at the player.
PointEntity Camera, Player

; And if you don't want the camera to pitch down...
RotateEntity Camera, 0, EntityYaw(Camera), 0


Do this each frame.


Farflame(Posted 2004) [#3]
Thanks alot :)


IPete2(Posted 2004) [#4]
Farflame,

Shawn's example above s excellent, but for a little more control look for Supercam in the Code Archives. This gives you lots of flexibility with little fuss - I always find it is a great way to move the camera.

In fact it is here:

http://www.blitzbasic.co.nz/codearcs/codearcs.php?cat=2


IPete2.


TomToad(Posted 2004) [#5]
For a simple camera follow, parent the camera to the player, then move the camera up and back a bit
player = LoadMesh("player.b3d")
camera = CreateCamera(player)
PostionEntity camera,0,5,-5 ;experiment with values to get the best effect for your game
PointEntity camera,player

now in the main code, the camera will follow the player whereever it moves. Downside is that the player might sometimes be blocked if polygons get inbetween the camera and player.