camera screwup?
Blitz3D Forums/Blitz3D Programming/camera screwup?
| ||
what is wrong with this code? i simply want it to follow my player, and move when my character moves. it does everything but move with my character.. code: thanks! |
| ||
Nothing wrong with it. Need more code. |
| ||
best solution: Player=CreateCube() Camera=CreateCamera(Player) or (...I think..) also possible: Player=CreateCube() Camera=CreateCamera() EntityParent Camera, Player,False do you know this link: http://www.blitzbasic.com/b3ddocs/docs.php |
| ||
didnt work..... |
| ||
didnt work.... You might need to supply a little more (i.e. ANY) information.... |
| ||
|
| ||
Take EntityParent out of your while/wend loop. You only need it once (BEFORE the loop). That will probably do it. Oh, by the way - if you aren't doing any collisions or animations, then UpdateWorld() is not required. |
| ||
still didnt work.... the camera looks like it moves instead of moving WITH the object... |
| ||
Hang on a minute....MoveEntity Player, 0, 0, (KeyDown(200)-KeyDown(208))*1 TurnEntity Player, 0, (KeyDown(203)-KeyDown(205))*1, 0...the hell is that all about?! You can't use KeyDown like that. [edit] Well, you can, but you really shouldn't. |
| ||
um, it assumes that both keys are 1 when pressed, so 1*1 is 1 :P is that the problem? and how can i fix it? |
| ||
No, it was just a passing comment. I don't have BB3D on here any more so I can't really test it, and its been years since I used it anyway. Are you sure you have the EntityParent parameters the right way around? |
| ||
yes? |
| ||
id love if there was a WORKING 3rd person camera code |
| ||
The code above cannot be the actual code you're using. I just installed BB3D to test this, and there's a parameter missing from CameraRange, and after I fixed that, all I get is a black screen. So I fixed that too by moving the cube infront of the camera instead of above it (?!), and when I press the cursor keys, the cube stays right where it should, relative to the camera. |
| ||
woops. i typed it out but didnt test it. sorry lol. im in a hurry. i did it from memory of what's in my REAL project, which just so happens to fire a nasa rocket 3d model into space that im working on, BUT in order to make THAT work, i need this camera to work. |
| ||
Well, for what its worth, with the two mentioned errors fixed, your code (above) works perfectly. You must be doing something different in your project but its impossible to say without seeing it. It should be quite easy to spot simply by comparing it to the above code. |
| ||
u wanna see it? ill turn the model into a cone, and comment out the texture |
| ||
here: |
| ||
If inair = 0 And inspace = 0 Then PositionEntity Camera, EntityX(player), EntityY(player), EntityZ(player)-10There's your problem - or at least a huge part of it. You're repeatedly repositioning the camera 10 units behind the player along the Z axis. Depending which way the camera is facing, the global Z axis could be any direction. What I'd recommend that you do, is set your camera positions ONCE at the start. Use multiple cameras (one for player, one for rocket, etc) and hideEntity all but the one you want the user to 'see' through. There's no overhead involved in doing this. |
| ||
so what should i change it to? i have to have the camera be positioned on the player or the rocket depending on what those variables are = to of course |
| ||
Just edited my last post with a suggestion. |
| ||
im not sure how to use 2 cameras. i find it easier to use 1 camera. |
| ||
that line WAS the problem. now. i got the player to camera to work. how can i get it when positioned on the rocket to rotate with the rocket, like it does the player? |
| ||
Multiple cameras are easy.Camera1 = CreateCamera() Camera2 = CreateCamera() Position camera 1 near your player, and camera 2 near the rocket, and parent them as normal. When you want to use the players camera: ShowEntity Camera1 HideEntity Camera2 ...and when you want to see the rocket: HideEntity Camera1 ShowEntity Camera2That's generally all there is to it. If you make both cameras visible at the same time, then one will render over the top of the other (which can be used for effects such as a HUD overlay etc - see CameraClsMode() for more info). As a footnote, you can also use CameraProjMode() to turn cameras on or off but personally I've always done it this way and I think its faster anyway. [edit] Set up the rocket camera in the same way as the player camera. This should work even if the rocket has been moved: PositionEntity Camera,entityx(rocket),entityy(rocket),entityz(rocket) ;place cam at same coords as rocket RotateEntity Camera,entityPitch(rocket),entityYaw(rocket),entityRoll(rocket) ;align camera with rocket MoveEntity Camera,0,0,-2 'move camera back a bit so we can see rocket EntityParent Camera,rocket |
| ||
FIXED! THANK you! |
| ||
EDIT: when i redid the code, it somehow fixed itself thanks anyway |
| ||
EDIT: ignore this |