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 / 3rd person shooter questions

Author
Message
Jonk
18
Years of Service
User Offline
Joined: 31st Jul 2005
Location: East of Java
Posted: 11th Jan 2014 09:37
OK here is my little bit of code and it seems to work so far but there are a few things I would like to do and I cant quite think how to go about them.

here is my code



My questions are;-

(1) How can I make the camera follow the player object when it turns? Ie I would ideally like the camera to always be facing the players back even when the player turns left or right.

(2) For some reason the Sky box moves with the camera when I look up and down using the mouse even though the ground mesh doesnt. Where am I going wrong with this?

(3) Ive had to set the animation speed for the Player object very fast to get a normal speed. Is there something wrong here?

The keys are "W,A,S,D" to move and mouse to look

I have included the media files to help

"There are no perfect ideas only perfect intentions"

Attachments

Login to view attachments
Derek Darkly
12
Years of Service
User Offline
Joined: 22nd Sep 2011
Location: Whats Our Vector, Victor?
Posted: 11th Jan 2014 16:29 Edited at: 11th Jan 2014 16:59
You left out MIKO.TGA, but no problem, we all have it.

CAM FOLLOW
To get the camera to follow the player you can either experiment with the SET CAMERA TO FOLLOW command, or you can manually control the position with your own custom commands, making sure you update it constantly inside your loop.

What I do is start the camera at the player position, orient it to the player's angle, then use a series of MOVE CAMERA/POSITION CAMERA, PITCH CAMERA UP/DOWN and ROTATE CAMERA commands to get the final distance and angle I want.



If you want something with a smoother reaction there's a pretty sweet example here:
A zelda-style camera control system?

Remember, anything you can imagine the camera doing is possible!


SKYBOX
You'll want your Skybox to be positioned with your player (also in the loop) so that it looks stationary:




Perhaps someone else can help with the animation issue, my home PC is too slow to run your sample properly.

D.D.
LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 11th Jan 2014 16:50
You're creating the extra camera 1, which is unnecessary, just use the default camera 0. You typically only need another camera if you are going to be looking at something from a different perspective at the same time.

In a 3rd person game, you will have difficulty moving the camera on the X axis, as the camera will end up moving under the terrain. If you need to see more of the sky, I would suggest backing up the camera a little further, but would only rotate on the Y axis.

As to the animation issue, you must have like a bazillion frames on the model. I don't know if you have access to 3D modeling software to edit it, but it probably needs to be done, as that will waste memory and slow down your game.

So many games to code.....so little time.
Jonk
18
Years of Service
User Offline
Joined: 31st Jul 2005
Location: East of Java
Posted: 11th Jan 2014 19:21
thanks for all the contructive Advice guys Ive been working on it and finaly got some 3rd person code that seems to work. thatwas just a free smaple model that came with dark basic pro Ive ditched it for a model from one of the FPSC packs its really nice and smooth now. Now to mess around with collisions yikes

"There are no perfect ideas only perfect intentions"
chafari
Valued Member
17
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 11th Jan 2014 22:02
Hi there

Knowing the actual Miko x,y,z and the target of Miko (newx , newy, newz), we can position the camera and point to Miko x,y,z:

How can we get the newx, newy, newz ?

as easy as moving Miko lat say 10 units getting x,y,z and movig Miko back again...then we position the camera in newx,newy+??,newz and point camera to actual x,y,z. This methode show us just the back side of our prota...not so beautifull.

Here is the code applied to you snippet. You will need to get collision to position your prota on the floor.




Another example using newvalue,newyvalue,newzvalue....




Cheers.

I'm not a grumpy grandpa
Jonk
18
Years of Service
User Offline
Joined: 31st Jul 2005
Location: East of Java
Posted: 12th Jan 2014 00:24
Thanks chafari that seems to work well. I particularly like the part about Miko's Behind lol

One more question .

When using the helper object to test for collisions is it best to use a box or a cube?

"There are no perfect ideas only perfect intentions"
chafari
Valued Member
17
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 12th Jan 2014 00:39 Edited at: 12th Jan 2014 00:47
A box is exactly the same as a cube. You could use intersect object to check if you have somthing around your player.

Example attached.

Cheers.

I'm not a grumpy grandpa

Attachments

Login to view attachments

Login to post a reply

Server time is: 2024-04-24 05:01:09
Your offset time is: 2024-04-24 05:01:09