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 Discussion / Follow the Object?

Author
Message
Area 51
19
Years of Service
User Offline
Joined: 3rd Feb 2006
Location: UNKNOWN
Posted: 16th Jul 2008 23:48
Hey guys. I've been tying to make a game where you are flying a jet and dogfighting with other jets. I tried to use the SET CAMERA TO FOLLOW OBJECT or whatever...but when the object turns in any direction, the camera does not rotate. I have tried many other methods, but none of them worked. What I want to happen is have the camera behind the object at all times while facing all directions.

Are we alone?
BN2 Productions
21
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 17th Jul 2008 01:19
I think TDK wrote a tutorial a while back explaining how that command works, try searching for it, it shouldn't be hard to find.

Ever notice how in Microsoft word, the word "microsoft" is auto corrected to be "Microsoft" but "macintosh" just gets the dumb red underline?
Area 51
19
Years of Service
User Offline
Joined: 3rd Feb 2006
Location: UNKNOWN
Posted: 17th Jul 2008 02:57
Alright, I got the command to work, but there is still a small problem. Sometimes, the camera turns the opposite way of the jet, giving a side view. This would normally happen when the camera is in collision with an object, but there is no object in the way and the collision flag is off. What's wrong?

Are we alone?
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 17th Jul 2008 04:53
@area 51

It sounds like you are proably using turn object, roll object, and pitch object. Using set camera to follow will give back strange results due to the rotation calculations. Try using the rotate object command instead of turn, roll, pitch .

Enjoy your day.
Area 51
19
Years of Service
User Offline
Joined: 3rd Feb 2006
Location: UNKNOWN
Posted: 17th Jul 2008 08:00 Edited at: 17th Jul 2008 08:02
Yes, that would work, but every axis stays in the same position for the object.

What I mean is: If you were to zrotate an object with all angles at 0, the object would roll to the left or right.Then if you were to yrotate it at 45 degrees, then use zrotate, the object would roll across a diagonal axis.

I plan to be xrotating, yrotating, and zrotating. So this will not work, unless there is a command in DBC that resets all angles to 0 without actually rotating the object. Then I could put that in my loop.


EDIT: These commands would work for walking though.

Are we alone?
BN2 Productions
21
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 17th Jul 2008 08:22
Quote: "What I mean is: If you were to zrotate an object with all angles at 0, the object would roll to the left or right.Then if you were to yrotate it at 45 degrees, then use zrotate, the object would roll across a diagonal axis."


Ok, yes and no, depending on a few things. One is the order of operations for your rotating. For instance, if you rotate on the y axis then the z axis, you will be diagonal. However if you rotate on the z axis then the y axis, you will be rolled and turned, but not diagonal. Here is a good order that should work

z axis
x axis
y axis

Now if you wanted to tilt it up, then it would require a little bit of math but can be done.

Ever notice how in Microsoft word, the word "microsoft" is auto corrected to be "Microsoft" but "macintosh" just gets the dumb red underline?
Area 51
19
Years of Service
User Offline
Joined: 3rd Feb 2006
Location: UNKNOWN
Posted: 18th Jul 2008 07:28 Edited at: 18th Jul 2008 17:03
But that's just it. I don't decide what order the the axis turn, the player of the game does.

I found that when the object is at 90 degrees on the y axis, the object still turns, but the camera goes the opposite direction because the angle seems to be hitting 90 and then descending back down. Bug? I think so.


SOLUTION: Ok, for anyone having the same problem as me, I have finally come up with an alternative. Instead of using the SET CAMERA TO FOLLOW command, you can place the camera directly behind the object without doing any complicated math.
Here's how it's done:


Thanks for the support.
- Area 51

Are we alone?
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 20th Jul 2008 03:04
Oh Yeah! I wasn't thinking! I've used that many times for camera orientations! Good Work! You can also create a camera that lags a bit in a similar way to SET CAMERA TO FOLLOW; again without math. Use CURVEANGLE:




Enjoy your day.
Area 51
19
Years of Service
User Offline
Joined: 3rd Feb 2006
Location: UNKNOWN
Posted: 23rd Jul 2008 00:05
Yeah, that works nicely.
My game should be coming to Program Announcements real soon. It's a simple game, only a couple hours of work was put into it in total.

Thanks for the code and the support!

Are we alone?

Login to post a reply

Server time is: 2025-06-07 06:44:21
Your offset time is: 2025-06-07 06:44:21