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 / 3d Camera problems

Author
Message
kamac
15
Years of Service
User Offline
Joined: 30th Nov 2010
Location: Poland
Posted: 17th Dec 2010 17:39
Okay, so i started 3d tests with simple racer game, and i dont know how to make camera follow my player .

The code:



Thanks!

Cheers!

~Kamac
kamac
15
Years of Service
User Offline
Joined: 30th Nov 2010
Location: Poland
Posted: 17th Dec 2010 19:13
I solved making it follow, but i have no idea how to make it go behind the player, when he's rotating :S.

Cheers!

~Kamac
Hodgey
16
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 18th Dec 2010 10:22
Hi, try this



A clever person solves a problem, a wise person avoids it - Albert Einstein
Sph!nx
17
Years of Service
User Offline
Joined: 3rd Dec 2008
Location: The Netherlands
Posted: 18th Dec 2010 11:32 Edited at: 18th Dec 2010 11:33
Well, I think it's best to regard the camera as a separate object, like the player or an enemy.

Simply code it so that it follows the player and act properly. This will give you much more freedom. You could have the camera interact with the walls and ceilings when you are inside (move closer to player when colliding or something) or detach the camera for cool looking cut-scenes!

Not really code help here. Just my two cents.

Regards,
Sph!nx
kamac
15
Years of Service
User Offline
Joined: 30th Nov 2010
Location: Poland
Posted: 18th Dec 2010 11:45
Thanks Hodgey

PS. Do you remember these lines?

or wrote them from sample ? They seem a little hard to me, i mean, i know what's sinus and cosinus but... lol

Cheers!

~Kamac
kamac
15
Years of Service
User Offline
Joined: 30th Nov 2010
Location: Poland
Posted: 18th Dec 2010 12:00
Oh, sorry for double-post and question which is probably being asked twice a minute. Is there any way for perfect polygon collision? I have the map made in wings 3d, it includes floor and walls. Its like a box without the top, like:
|_| and the normal box has the top over the _ . Well, when i try to detect the collision that way, it just simply cannot be done, because DBPro doesn't see that there is a space between four walls

|X| on X is free space , which he doesnt see

Cheers!

~Kamac
Kira Vakaan
17
Years of Service
User Offline
Joined: 1st Dec 2008
Location: MI, United States
Posted: 18th Dec 2010 20:17
Quote: "PS. Do you remember these lines?
camx = (-sin(angle)*distance)+object position x(1)
camz = (-cos(angle)*distance)+object position z(1)
or wrote them from sample ? They seem a little hard to me, i mean, i know what's sinus and cosinus but... lol "


Those lines simply calculate the position of the point that is "distance" units behind object 1's location, based on which way the object is facing. I would recommend getting comfortable with that kind of math. I can only make your life easier, and you'll probably encounter it frequently in your game development career. However, DBPro provides some simple functions to take care of simple trig like that for you. You can replace those lines with this:

These lines do exactly the same thing, and are easier on the eyes for trig beginners, but they will become limiting when you need to do more complex things.

As for your collision problem, it sounds like DBPro is either trying to use box collision on the map, or your face normals are backwards. But, assuming that you can actually see the walls and floor while you are inside the box, it is probably not a normal problem as they would've been culled by DBPro.

Since you have a collision issue, I'm sure someone around here is going to suggest getting Sparky's DLL, which I highly recommend myself, but I think it's important that you figure out what you were trying to use first. How are you setting up your collision?

kamac
15
Years of Service
User Offline
Joined: 30th Nov 2010
Location: Poland
Posted: 18th Dec 2010 21:36
I am setting it up by commands:


That's it, but it seems like DBPro see's the map as a box.

Cheers!

~Kamac
Kira Vakaan
17
Years of Service
User Offline
Joined: 1st Dec 2008
Location: MI, United States
Posted: 18th Dec 2010 22:51
Try removing set global collision on. I think that command tells DBPro to do what it thinks is best, regardless of what you told it to do previously.

kamac
15
Years of Service
User Offline
Joined: 30th Nov 2010
Location: Poland
Posted: 19th Dec 2010 08:19
It still doesnt work here's the full code:


Cheers!

~Kamac

Login to post a reply

Server time is: 2026-07-21 07:03:47
Your offset time is: 2026-07-21 07:03:47