Mark's chasecam
Blitz3D Forums/Blitz3D Programming/Mark's chasecam
| ||
I am using Mark's chasecam code, but I want 'markio' to stay the same distance from the camera no matter how fast he is going, so I changed this line: TranslateEntity entity_camera,dx*.1,dy*.1,(dz*.1)+speed but the camera didnt centre itself properly and ended up at a strange angle, can anyone help? |
| ||
I just tried it and the camera worked fine. Idid not see a angle. Are you sure you did not change something else? |
| ||
Function CreateChaseCam(entity_camera,entity ) EntityParent(entity_camera,0) camera_target=CreatePivot( entity ) heading=CreatePivot( entity ) PositionEntity camera_target,0,4,-10 PositionEntity heading,0,4,20 End Function Function UpdateChaseCam(entity_camera,speed#) dx#=EntityX(camera_target,True)-EntityX(entity_camera,True) dy#=EntityY(camera_target,True)-EntityY(entity_camera,True) dz#=EntityZ(camera_target,True)-EntityZ(entity_camera,True) TranslateEntity entity_camera,dx*.1,dy*.1,(dz*.1)+speed PointEntity entity_camera,heading,EntityRoll(piloted_ship) End Function I am using a simplified version, when I add +speed the camera doesnt centre itself properly but when I leave it out it centres itself normally |
| ||
In effect that *.1 bit for each axis is the speed the camera will translate towards the target in that axis. So change that. It is not an absolute speed of course, it divides the distance down, so it will take progessively smaller steps, a bit like the rate parameter on aligntovector. So just remove the *.1 from dz*.1 to keep the Z distance constant. You could have the camera transition at an absolute rate if you prefer. To do that get the distance... dist#=sqr(dx*dx+dy*dy+dz*dz) Then if the distance is greater than the speed divide each component by the distance (normalising the vector so the sum of the components will be one) and then multiply each component by the speed... if dist>speed Then dx=dx/dist*speed dy=dy/dist*speed dz=dz/dist*speed Endif Then translate by dx,dy,dz Not tested though, so it may need some of that old fine tuning. |
| ||
thanks Ratt and DJ |