ParentEntity not stiff

Blitz3D Forums/Blitz3D Programming/ParentEntity not stiff

Jerome Squalor(Posted 2007) [#1]
Hello!!!
Ok, there is one thing that is hindering me from completing many of the games i start. When I parent a camera to an object, the camera turns really stiffly. How do I make it so that when the object is turned, it turns a few degrees, and then the camera starts turning?

Can you guys explain a lot, 'cause i have absolutely no idea how to accomplish this.

Thnx in advance!


Stevie G(Posted 2007) [#2]
Try something like this by playing with the OffsetZ and Smooth values.

There are other, better examples in the archives.

Stevie

Function CAMERAfollow( CAMERA, Entity , Smooth#=.01, OffsetZ#= -10 )

  tformpoint 0,0,OffsetZ, Entity, 0
  Tx# = ( tformedx() - entityx( CAMERA ) ) * Smooth
  Ty# = ( tformedy() - entityy( CAMERA ) ) * Smooth
  Tz# = ( tformedz() - entityz( CAMERA ) ) * Smooth
  TranslateEntity CAMERA, tx, ty, tz
  pointentity CAMERA, Entity

end function



Jerome Squalor(Posted 2007) [#3]
I know this is asking a lot, but is there any way you can explain each line, because i have no idea what the tformed commands do, or how to use them.


boomboom(Posted 2007) [#4]
There are alot of code examples for this in the code archives.


Stevie G(Posted 2007) [#5]
Search for tformpoint etc.. and you'll get some good explanations.

p.s. There is a nice smart cam function in the archives.


Ross C(Posted 2007) [#6]
Parent a pivot to your entity you want the camera to follow.

Position the pivot where you'd like the camera to be when it's resting.

Do all this befoire your main loop starts.

global entity = >>>>> YOUR ENTITY YOU WANT THE CAMERA TO FOLLOW <<<<
global camera = createcamera() ; your actual camera
global cam_pivot = createpivot() ; the place you want the camera to be
entityparent cam_pivot,entity
positionentity cam_pivot,0,10,-20 ; 10 being the height above the entity you want to follow, and -20 being the distance behind it.


Now, every loop, do the following, immediately after each other.

pointentity camera,cam_pivot ; Points camera at the pivot
moveentity camera,0,0,entitydistance(cam,cam_pivot)/30
pointentity camera,entity ; point the camera at the entity you want the camera to follow


That should be you sorted. I don't have blitz3d installed, but it should work :o) Whats happening is, the cam_pivot is the point the camera always tries to be. That's why i'm pointing the camera at it and moving it towards it. NOW, i'm using the distance between the CAMERA and the CAM_PIVOT to produce a smooth movement, as the distance between them decrease, the slower the camera will move.

Then, i simply point the camera back at the entity.

This code is heavily based on Rob Farley's smooth cam. Kudo's to him!


Stevie G(Posted 2007) [#7]
Ross, that's exactly the same as what I just posted only done slightly differently.


Ross C(Posted 2007) [#8]
Sorry man... Didn't realise that :D

Stick with stevie's code! That's what i get for not reading anyone else's posts.