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 Following

Author
Message
Lord Lurd
18
Years of Service
User Offline
Joined: 23rd Apr 2006
Location:
Posted: 16th Jun 2006 20:33
Hi

I'm going to try my best to explain my problem. I have my set to follow my character like this:

set camera to follow ox#,oy#,oz#,camera angle y(),250,Object Position y(2)+50,10,2

Where ox#, oy#, and oz# all mean object positions x,y,and z respectively.


This way my camera will follow my player, and when the camera stops, it will follow at the angle it was last set at. The problem is, that when the camera angle is at 180 from its starting angle (when ther room was loaded) my controls become reversed. Is there a way to fix this and make a more "free" camera?

Here is my movement code:



Where Spd# is the speed of the object.

Thankyou for looking! Help will be appreciated!
Hazviz
18
Years of Service
User Offline
Joined: 12th Jun 2006
Location: Alnwick, UK
Posted: 16th Jun 2006 20:57
I am not quite sure if this is what you looking for, but I will attempt to give one way of producing a camera that appears to be more... free..



This is the code I am currently using in my 3rd person engine I am workin on. Though IMO it needs a little tweaking as it gets a bit buggy if you move your mouse pretty fast whilst holding RMB.

This might not help, then again it might. Either way, Good luck with it all!
Lord Lurd
18
Years of Service
User Offline
Joined: 23rd Apr 2006
Location:
Posted: 16th Jun 2006 21:39
Thankyou for your response.
This camera did help, but it did not solve the issue of the controls for the character. When the camera angle is rotated 180 degrees from its starting angle, my character's controls become reversed. Please look at my movement code in my first post.

Thanks for trying!
Any more help will be appreciated!
Hazviz
18
Years of Service
User Offline
Joined: 12th Jun 2006
Location: Alnwick, UK
Posted: 16th Jun 2006 21:57
Im not on my main computer at the moment. But when I get on it i will try out your code and have a fiddle about.

I would hazard a guess that it has something to do with the way you are specifiying "yrotate object ColliderObjNum, 180".

Try removing the "yrotate" commands from the upkey() and downkey() if statements and I will get back to you soon
RUCCUS
19
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 16th Jun 2006 22:51
Unless he means that once the cam is at 180 then pressing the left key makes you go right and vise versa for the right key going left, which would make perfect sense... Its like a radio controlled car, when it comes towards you the controls are always reversed. But if you mean that when you're pressing the leftkey its going to the camera's left and vise versa for right, then you might want to show some code.

Lord Lurd
18
Years of Service
User Offline
Joined: 23rd Apr 2006
Location:
Posted: 16th Jun 2006 23:15
Ruccus, thats exactly what I mean.

The radio controlled car example that is. Is there a way to fix this, or is this how the camera is?
Hazviz
18
Years of Service
User Offline
Joined: 12th Jun 2006
Location: Alnwick, UK
Posted: 16th Jun 2006 23:29
If that is the case you could simply use 2 if statements... Like...



That should work.
I think... lol
Lord Lurd
18
Years of Service
User Offline
Joined: 23rd Apr 2006
Location:
Posted: 17th Jun 2006 00:39
Thanks its getting better

When the angle reaches around 0 however, my character rapidly moves left and right and gets "stuck" because of the IF camera statements.

Here is how I have the code:



Any way to fix this?
Hazviz
18
Years of Service
User Offline
Joined: 12th Jun 2006
Location: Alnwick, UK
Posted: 17th Jun 2006 00:42
Hmmm, not to sure. That will probably be because of non-exact numbers.

Try changing both 180's in the two camera angle if statements to:

180.0#

ie:



Anyone else have any ideas?
Lord Lurd
18
Years of Service
User Offline
Joined: 23rd Apr 2006
Location:
Posted: 17th Jun 2006 04:59
Nope it didn't work :S

The object starts jerking back and forth at the camera's y angle extremities.

This might be easier if you think like this, and I should have worded it like this before. "How can my object go forward when I press the up key, backwards when I press the down key, left when I press the left key, and right when I press the right key, Nomatter what the camera angle is?"

Thanks
Hazviz
18
Years of Service
User Offline
Joined: 12th Jun 2006
Location: Alnwick, UK
Posted: 17th Jun 2006 06:26
Well thats easy...



Try that in your game...
Hope it helps.
Lord Lurd
18
Years of Service
User Offline
Joined: 23rd Apr 2006
Location:
Posted: 17th Jun 2006 21:33
Thanks. Now we're getting somewhere

It didn't let me put -Spd# in the code... it gave me a compile error. However it worked fine when I changed that to 1-Spd#.

The Forward and Backward functions are doing great right now but I also need the character to rotate depending which direction its facing. Example, when going forward, it needs to face forward, when going backwards it needs to face backwards, etc.

Also for some reason, he won't go left or right. He will turn once, because he is facing the to the front in the beginning when the room is loaded. Once I have turned once (lets say I turned right) If I press the left key now, he will go in the opposite direction!

Thankyou for your time. I hope you can help! I really appreciate it!
Hazviz
18
Years of Service
User Offline
Joined: 12th Jun 2006
Location: Alnwick, UK
Posted: 17th Jun 2006 22:11
Hey,
It's no problem, I am glad we are getting somewhere.

Could you please post all of your movement code so that I can test it out for myself and try and get it working for you, as it is a little bit hard to fault find without it.

I have a feeling we will fix it very soon
Coder#05
18
Years of Service
User Offline
Joined: 26th Oct 2005
Location: Denmark
Posted: 17th Jun 2006 22:30 Edited at: 17th Jun 2006 22:34
The move object +/- , moves the object be looking at the current y angle of the object, so when you want your object to turn around when pressing the downkey, your object y angle changes, so you dont need to add a negative speed value to the move object command.
Just do this(When you press the down key):
1. Turn the object around, and (maby) have a variable hold wheter or not the object has been turned around(Object_facing_backwards=1)
2. Just move the object


Just an idea,if you dont figure it out, maby i will write a quick code snippet to show you.(When i get home from vecation)
EDIT:
Not sure if im getting your question right

easy comes easy goes
Lord Lurd
18
Years of Service
User Offline
Joined: 23rd Apr 2006
Location:
Posted: 17th Jun 2006 23:36
Sure



If it will help you, I will attatch my project with my media in this zip file. My code is an edit of G Man's Code.i made it third person and added a jump feature. Right now I'm making the engine for my game. (You use the C button to jump and I kinda added the space and shift keys to rotate the camera for a "look around")

Thanks a bunch!

Attachments

Login to view attachments
Coder#05
18
Years of Service
User Offline
Joined: 26th Oct 2005
Location: Denmark
Posted: 18th Jun 2006 00:27
Hmm, Im still not completely sure what your problem is but,i put together some movement code, doing what i said before, hope you figure it out.
(Note that i dont use the move object command set(Im not used to doing so), but i commented the code, so you sould be able to do something like that in your code)


easy comes easy goes
Lord Lurd
18
Years of Service
User Offline
Joined: 23rd Apr 2006
Location:
Posted: 18th Jun 2006 01:52
@ Coder#05: Hmmm. That Code Snippet wont compile :S it says variable p. doesnt exist on line 43...
Coder#05
18
Years of Service
User Offline
Joined: 26th Oct 2005
Location: Denmark
Posted: 18th Jun 2006 02:08
Compiles fine here(maby the version of dbproo you use?, if so try and make variable p to an array instead), This is the last time i can test it. Because im headed for Norway tomorrow.You might wanna reverse the strafeing left and right when "faceing backwards", and im not sure if this is exactly what you are looking for.
Godnight

easy comes easy goes
Lord Lurd
18
Years of Service
User Offline
Joined: 23rd Apr 2006
Location:
Posted: 18th Jun 2006 02:13
Sorry I don't know how to do that

I will mess around with it though...
RUCCUS
19
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 18th Jun 2006 03:16 Edited at: 18th Jun 2006 03:16
I think the problem here is that he thinks the controls are reversing, like I said before, when something is coming towards you, the controls will always be reversed. If you unreverse them, it'll feel weird.

An example:



The movement for the sphere in that program is completely normal, like I said, if you switched this it would feel weird to IMO everybody playing.

Lord Lurd
18
Years of Service
User Offline
Joined: 23rd Apr 2006
Location:
Posted: 18th Jun 2006 19:48
Well I know the controls aren't reversing, it just looks like that. But I've seen in many 3rd person games that you go forward if you press up and backward if you press down nomatter what angle the camera is at. Is there a way to do this?

Thanks
RUCCUS
19
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 19th Jun 2006 02:20
Ah, I see. The problem is you're talking about 3rd person (when the camera stays behind the object) and you're using 2nd person (when the camera always points to the object). Search 3rd person in the forum searches to find out how to get a real 3rd person game working.

Lord Lurd
18
Years of Service
User Offline
Joined: 23rd Apr 2006
Location:
Posted: 19th Jun 2006 02:23
Thankyou Ruccus, I found just what I ws looking for

Topic Solved

Login to post a reply

Server time is: 2024-09-25 01:25:17
Your offset time is: 2024-09-25 01:25:17