Moving the camera around with the mouse
Blitz3D Forums/Blitz3D Programming/Moving the camera around with the mouse
| ||
I'm making an fps and this is the code i'm using to move the camera, but whenever i look up or down too fast the camera turns upside down. I'm not sure how to fix this though. TurnEntity player, 0, -MouseXSpeed()/6.0, 0 TurnEntity camera, MouseYSpeed()/6.0, 0, 0 If EntityPitch(camera) < -80 RotateEntity camera, -80, EntityYaw(camera), EntityRoll(camera) EndIf If EntityPitch(camera) > 80 RotateEntity camera, 80, EntityYaw(camera), EntityRoll(camera) EndIf |
| ||
After all of that putRotateEntity camera,EntityPitch(camera),EntityYaw(camera),EntityRoll(camera);Doesn't work rightEdit: RotateEntity camera,EntityPitch(camera),0,0;Works EntityPitch will stop it from flipping. |
| ||
I entered that and now whenever i look up or down at all the camera goes upside down no matter what speed the mouse is going. |
| ||
Is there any other code controling the camera? (Or did you figure this out?) |
| ||
Hmm I just tried it myself even though I know I've used it before... this time it didn't work. I'll go check and see whats wrong hopefully I'll find it. |
| ||
Pitch, yaw and roll affect each other. Maybe it is safer to use a variable instead?x# = x# + MouseXSpeed()/6.0 y# = y# + MouseYSpeed()/6.0 If y < -80 Then y = -80 If y > 80 then y = 80 RotateEntity camera, y, 0, 0 RotateEntity player, 0, -x, 0 |
| ||
Well I figured it out, we weren't supposed to have the EntityYaw and EntityRoll when using RotateEntity |
| ||
I meant for an FPS not moving the camera around an object. |
| ||
I tried this code from Warner and it stops the camera from turning upside down, but i still can't look left and right. |
| ||
Um, my way IS for FPS. It's not moving around an object, the cubes and spheres are just there so you can tell if you're flipping or not. But I'm pretty sure every FPS game that allows you to look up, down, left and right use a Camera parented to a Pivot. |
| ||
k i guess my code is just messed up thx for the help anyway tho |
| ||
The code from Warner needs to beRotateEntity camera,y,x,0 |
| ||
What's with the odd names? A51M15X AJ00200 |
| ||
EntityPitch returns dodgy values, unless you're using it in combination with the other 'get rotation' commands http://www.blitzbasic.com/b3ddocs/command.php?name=EntityPitch&ref=3d_cat To fix that, you need to cache the pitch value in a variable. I also tend to use a gimbal approach, with different pivots used for yaw and pitch. http://www.blitzbasic.com/codearcs/codearcs.php?code=1137 |
| ||
Function freelook(camera) Local msX#, msY#, p# Local multi# multi = 0.125 msX=MouseXSpeed()*multi msY=MouseYSpeed()*multi MoveMouse GraphicsWidth()/2, GraphicsHeight()/2 p = EntityPitch(camera)-msY ; invert If p>85 Then p=85 EndIf If p < -85 Then p=-85 EndIf RotateEntity camera,p,EntityYaw(camera)-msX,0 End Function Working freelook - pulled out some sample code somewhere can't remember where the original source was. |
| ||
Maybe this code could help. |
| ||
Whats with the odd names? Whats with your name? Its -ugh- NormalMine is a LONG STORY |
| ||
Your name is a LONG STORY but if I spelt out my user name in full, it would be wayyy too LONG. GIA in GIA_Green_Fire_ comes from 3 things. G = Favorite color(Green) I = Somewhat prefer it over fire(Ice) A = I like it(Archer) I just stuck those three things together and made GIA. Then for some random reason I put _Green_Fire_ after it. I don't know why I don't just use Green Ice Archer or G.I.A. for everything. |
| ||
Thank you Bobysait |