Need a Better Camera than ParentEntity(player)!!!

Blitz3D Forums/Blitz3D Beginners Area/Need a Better Camera than ParentEntity(player)!!!

Crazy4Code(Posted 2005) [#1]
I want my camera to be a little better than ParentEntity. The player will fly around and I need want the camera to not only point at the back, but I want it to slightly show the sides of the ship and the top or bottom if your going to up or down. If you've played Ace Combat or probably any other flight game, you know what I mean. I don't know how easy or hard this will be, but, anyone know what I mean and how to do it?


Ross C(Posted 2005) [#2]
Easy peasy man :o)

Have a pivot parented to the craft (camera_pivot). Move it to the location you want the camera to be. Then, each frame do:

PointEntity camera, camera_pivot
MoveEntity camera,0,0,EntityDistance(camera,camera_pivot)/30
PointEntity camera,craft


Smooth camera :o)


So you code would look something like:


Global camera = CreateCamera()

Global craft = loadmesh("craft.b3d")

global camera_pivot = createpivot()
entityparent camera_pivot,craft

moveentity camera_pivot,0,0,-10 ; or whatever distance you want the camera to be at


while not keyhit(1)

   PointEntity camera, camera_pivot
   MoveEntity camera,0,0,EntityDistance(camera,camera_pivot)/30
   PointEntity camera,craft

   updateworld
   renderworld
   flip
wend



Crazy4Code(Posted 2005) [#3]
Thanks, I don't understand how it works, but I managed to fit it into my code. I have one problem though. It's hard to explain. Ya know how in games, usually if you don't turn the plane or ship or whatever, it turns back to horizontal? Right now, the ship flips all around and goes upside down and stuff. I could probably figure it out myself, but anyone know what to do?


Ross C(Posted 2005) [#4]
Is your camera working the way you want?


Crazy4Code(Posted 2005) [#5]
My camera is working the way I want, but the ship flips over sometimes, and the controls and theship is reverse.


Crazy4Code(Posted 2005) [#6]
Okay, I fixed it. Nevermind. Thanks!!!!


Crazy4Code(Posted 2005) [#7]
Okay, I decided to use this airplane from one of the demo's that came with blitz, but when you use it, it moves as if the side of it were the front. It's a .x file and I don't have anything except mesh viewer to open it so I can't turn it around. I tried rotating the plane and the camera, but it just ends up the same once you start moving. Can anyone either 1. tell me a program I can use to open and turn around a .x mesh? or how to turn it around without the camera following it?


Yan(Posted 2005) [#8]
mesh = Loadmesh("mesh.x")
RotateMesh mesh, 0, 90, 0



Crazy4Code(Posted 2005) [#9]
oh, cool :) lol. I need to read the whole Command Reference


Ross C(Posted 2005) [#10]
The mesh commands perminatly alter the actual mesh. The way the entity structure is structure is sort of like a Type Object.


Type Entity

   Field Mesh
   Field X_Entity_Rot
   Field y_Entity_Rot
   Field z_Entity_Rot

End type



The mesh is a child so to speak of the entity. When you use entity commands, the parent entity (think of it as a pivot), is rotated, moved scaled... etc etc