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.

DarkBASIC Professional Discussion / set camera to follow object with up down look ability?

Author
Message
Bago
18
Years of Service
User Offline
Joined: 7th Jan 2008
Location:
Posted: 27th Jul 2011 03:31 Edited at: 27th Jul 2011 03:33
I have tried to add the ability to look up and down with a follow camera (set camera to follow object position) but it glitches.

I modified the code for follow camera from dark physics vehicle demo.
Darkbasic Pro\Projects\Dark Physics\Demos\Vehicles\Test Drive



It works with the code below to make my character turn left and right and have the camera still following.



The problem with ading code to allow the camera to look up and down similar to the way left and right works it changes the way the camera functions from look left and right to circle the character left or right and disables the camera looking left or right.



Is it even possible to make the follow camera look up and down?
Any help is appreciated.

Bago
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 27th Jul 2011 13:47 Edited at: 27th Jul 2011 13:48
Do you want to rotate the camera free and folow all the time to your character ?

cheers.

I'm not a grumpy grandpa
29 games
20
Years of Service
User Offline
Joined: 23rd Nov 2005
Location: not entirely sure
Posted: 27th Jul 2011 23:06
I'm going to pre-empt the answer to chafari's question and just assume that you want to do some kind of 3D person camera control.

Yes you can get the camera to look up and down when using the set camera to follow command. You have to alter the angle of the camera around its x-axis after the "set camera to follow" command, see the demo below.



The only issue with this is that, when looking up and down, the camera does not pivot about the player object (the cube).



If you want smoothing with this (i.e. a bit like the camera is following behind on a bit of elastic) then you'll need to add in some extra code.

Anyway, hope this helps.
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 27th Jul 2011 23:44
Quote: "I'm going to pre-empt the answer to chafari's question "


That`s what I thought...but I prefer to wait until he confirm

Your examle is ok and to avoid camera going into the floor or ceiling we need an extra hidden object or play with x,y,z .

Cheers.

I'm not a grumpy grandpa
29 games
20
Years of Service
User Offline
Joined: 23rd Nov 2005
Location: not entirely sure
Posted: 28th Jul 2011 00:08
Quote: "... I prefer to wait until he confirm"


You're probably right, it wouldn't be the first time that my powers of telepathy have failed me

Quote: "to avoid camera going into the floor or ceiling we need an extra hidden object or play with x,y,z"


That's one one doing it or, because the camera is being moved backward from the cube, you could also use sphere casting to work out if there's a wall/floor/ceiling between the cube and the camera and then get the static collision coordinates to work out the position of the camera. I'd recomend sphere casting rather than straight ray casting as it's always best to keep the camera a small distance away from objects to prevent object clipping.
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 28th Jul 2011 00:27
Quote: "You're probably right, it wouldn't be the first time that my powers of telepathy have failed me "


I`m with you.
What I do for the camera in third person, is add an extra object that follows the player in the same way as the camera do, and then place the camera on its coord. so if this object collision, just move towards the player ...if not it goes back to its position...so we asure, that the camera never will go into the walls or whatever.


Cheers.

I'm not a grumpy grandpa
Bago
18
Years of Service
User Offline
Joined: 7th Jan 2008
Location:
Posted: 28th Jul 2011 04:04 Edited at: 28th Jul 2011 06:01
Thanks for your responses.

Yes I wanted to do a 3rd person camera control.

This helps much, and I now have it is almost working in my code.
Making a seperate files with your code modifing it with my media works without any problems. Implementing into my game code is causing some problems, the camera decides to be inside my character and it looks the way I move, the camera goes into the correct position for a short while as the character jumps.

I only use regular darkbasic commands and Dark physx so far. I've attached what I have so far but am still working on fixing it up.

There is the problem that my character is facing the wrong way and I couldn't rotate him in 3d studio max (trial) without mangling my simplistic animations I had done, so I rotated it in darkbasic pro and adjusting all movement accordingly.

EDIT: I found out the jump code causes the problem with the camera being inside the character. I also found out the strafe code causes the charater to stop rotating with the mouse.

Beause my strafe code is:



The only way I can see to get my strafing to work with the follow camera is to remove the ability to turn while strafing which makes it rather bad.
Bago
18
Years of Service
User Offline
Joined: 7th Jan 2008
Location:
Posted: 28th Jul 2011 08:34
I have gone to my last backup where everything worked fine except that I don't have the ability to look up and down with the mouse.

As I can only place one download per post thats the reason for the next.

29 games
20
Years of Service
User Offline
Joined: 23rd Nov 2005
Location: not entirely sure
Posted: 28th Jul 2011 22:51 Edited at: 28th Jul 2011 22:53
Unfortunately I don't have Dark physx so I can't run you're code and I can only guess at what the "phy move character controller 2, 270" command is doing.

Quote: "I found out the jump code causes the problem with the camera being inside the character"


Below is a modified version of the demo I gave you with some simple jump code added.




Quote: "I also found out the strafe code causes the charater to stop rotating with the mouse"



This could be due to the fact that the key press controls are either over-riding or clashing with the mouse commands, ie they are both trying to turn the object at the same time. Is there no way you can do the strafing without having to rotate the camera? I also think that the "TURN OBJECT" commands and the "ROTATE OBJECT" commands (which I used in my demo) don't mix very well and I tend to use either one or the other, not both.


Quote: "There is the problem that my character is facing the wrong way and I couldn't rotate him in 3d studio max (trial) without mangling my simplistic animations I had done, so I rotated it in darkbasic pro and adjusting all movement accordingly."


Try using the FIX OBJECT PIVOT command after you've rotated the model once it's loaded. This should fix the orientation of the model. If it doesn't try using the YROTATE OBJECT command instead of the TURN command.

Just out of interest, have you tried your code using the model as it is (i.e. just with it facing backward) or with a placement model to see if it works. I'd recommend doing this as it could eliminate a potential source of problems whilst you sort this out.

As I said, I don't have dark physx so I can't run your code without completely rewriting it (at which point it will no longer be your code) so maybe someone else can leap in here and help you out.
Bago
18
Years of Service
User Offline
Joined: 7th Jan 2008
Location:
Posted: 29th Jul 2011 04:16 Edited at: 29th Jul 2011 09:59
Thank you "Fix Object Pivot 2" helped get my character facing the right way without needing to reverse all controls. I can still use "turn object left 2, 180"

One thing I find really weird is that through my whole code there is not on piece that makes the camera stick with the follower object (object 4). Yet the camera stays with it.

I think the problem with looking up and down may be the "point object 4,object position x(2),object position y(2),object position z(2)" which is used in the main loop in the function Camera(). But no matter what I put the Y value it still looks at the character.

I'm thinking even I could try adding varibles to the "set camera to follow object position x(2), object position y(2), object position z(2), angle#, dist#, hight#, 3, 0" to make the dist# and hight# change in a circle-ish way to look up and down with the mouse y. Have the camera go higher and closer to look down, have the camera go closer and move it down to look up.

I'll be back with the results

Edit: mousey() with "SET DISPLAY MODE 960, 600, 32" and setting the mouse cursor in the middle of the screen (position mouse 480,300) from that spot I can add/subtract the difference to the camera hight# and I have it able to move up and down, the only thing is the camera is not looking at the character as it moves up or down and just looks the way the charater faces. Then I added "point camera object position x(2), object position y(2) + 90, object position z(2)" and now it faces correctly. (+90 because the camera is above the character looking down a little)
The Slayer
Forum Vice President
16
Years of Service
User Offline
Joined: 9th Nov 2009
Playing: (Hide and) Seek and Destroy on my guitar!
Posted: 29th Jul 2011 13:09
Quote: "One thing I find really weird is that through my whole code there is not on piece that makes the camera stick with the follower object (object 4). Yet the camera stays with it."

That's because you always position object 4 at the same position as object 2:



and later in your code, you set the camera to follow object 2:



That's why the camera is also following object 4.

Cheers

Bago
18
Years of Service
User Offline
Joined: 7th Jan 2008
Location:
Posted: 29th Jul 2011 14:09
Thanks The Slayer I didn't even notice that.

Now I've actually got a look up and down but I think its going to be very fun (difficult) to get my charater to shoot with it. This time I've added the compiled exe file with it.

Login to post a reply

Server time is: 2026-07-10 19:07:07
Your offset time is: 2026-07-10 19:07:07