Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Camera Question

Author
Message
vorconan
18
Years of Service
User Offline
Joined: 4th Nov 2006
Location: Wales
Posted: 18th Nov 2007 13:37
I'm having a bit of trouble with my camera code at the moment, I seem to make the most simple mistakes that make the program seriously fustrating, here goes. Basically I'm trying to implant code into the existing camera code that will allow the player to look up/down, the problem seems quite simple but I can't get my head around it, here's my existing code:



The problem with this is that the camera continually springs back to the object's Y position instead of staying where it is. Does anyone have a way of fixing this, it would be very much appreciated.

Thanks a lot



vorconan
18
Years of Service
User Offline
Joined: 4th Nov 2006
Location: Wales
Posted: 18th Nov 2007 15:52
Oh and one more thing (the last thing for now I swear), how would I make the camera point to a position next to the player? I'm not sure how to find a point on the object's local axis, only the global axis.

Thanks again



Doc
17
Years of Service
User Offline
Joined: 6th Nov 2007
Location:
Posted: 19th Nov 2007 05:55
I'm not entirely sure if this is what you want, but simple camera functionality should be something like:



to make the camera look directly left, or directly right, use:
yrotate camera 0, camera angle y(0)+90
or -90 to look in the other direction.

I'm really sorry if this isn't what you menat, if it isn't could you explain it better? However, in any case, I believe the problem to your camera "springing back to where it was" is that the rotation commands are global, so if you want to increase the angle of something you must add it to it's current angle.
ex: if an object is currently rotated 50degrees, and I want to rotate it an additional 15 then you would do something like:
yrotate object num, (50+15)

Hope this helps you at all.

The right man in the wrong place can make all the difference in the world. -- GMan
vorconan
18
Years of Service
User Offline
Joined: 4th Nov 2006
Location: Wales
Posted: 19th Nov 2007 21:02
I know about the basic camera functionality, but I'm following a character so need to use trigonometry and point to the player, so the basic camera commands aren't what I need, in this case anyway. I've updated the code a little bit anyway, it still springs back, I think this is because of the MouseMoveYVar not updating but I'll have to check.





vorconan
18
Years of Service
User Offline
Joined: 4th Nov 2006
Location: Wales
Posted: 20th Nov 2007 21:44
Anyone have any ideas?



Doc
17
Years of Service
User Offline
Joined: 6th Nov 2007
Location:
Posted: 20th Nov 2007 22:51
Maybe the command "set camera to follow" will do the trick.

The right man in the wrong place can make all the difference in the world. -- GMan
vorconan
18
Years of Service
User Offline
Joined: 4th Nov 2006
Location: Wales
Posted: 20th Nov 2007 23:20
No, you misunderstand. I have the camera following the player, I just want a way of increasing the variable CAMPOINTY with the mousemovey() command and keep it at that value instead of resetting back to the original value.



Doc
17
Years of Service
User Offline
Joined: 6th Nov 2007
Location:
Posted: 21st Nov 2007 06:59
Well, in that case try changing the line:
MouseMoveYVar = MouseMoveY()

to this:
MouseMoveYVar = MouseMoveYVar + MouseMoveY()

The right man in the wrong place can make all the difference in the world. -- GMan
vorconan
18
Years of Service
User Offline
Joined: 4th Nov 2006
Location: Wales
Posted: 21st Nov 2007 17:37
It has been changed as you'll see in the last bit of code I posted



I just have no idea why it keeps resetting.



Scorpyo
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: italy
Posted: 22nd Nov 2007 19:37
Have you made those variables globals?
revenant chaos
Valued Member
17
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Robbinsdale, MN
Posted: 23rd Nov 2007 20:23
thats what it sounds like to me Scorpyo. If a variable is declared within a function, either the variable needs to be global or constantly returned from, and plugged back into the function.
Ex:

or
vorconan
18
Years of Service
User Offline
Joined: 4th Nov 2006
Location: Wales
Posted: 24th Nov 2007 00:59
Ouch, how did I miss that? I was so sure I made it a global, thanks guys, that helped me loads.

Thanks again



Login to post a reply

Server time is: 2024-11-25 09:38:27
Your offset time is: 2024-11-25 09:38:27