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 / set camera to follow

Author
Message
helpme
20
Years of Service
User Offline
Joined: 28th Jan 2006
Location:
Posted: 2nd Jul 2007 08:41
I am trying to get the camera to follow the character using:
set camera to follow x#, y#, z#, a#, 10, 5, 100, 0

It works when you move forward or backwards, and it works when you turn, but if you turn while moving the character goes off the screen. Also, if you go forward then backwards the camera jumps. How do I fix this?
qwe
22
Years of Service
User Offline
Joined: 3rd Sep 2003
Location: place
Posted: 2nd Jul 2007 09:25
you could make your own camera follow function

the function would be something like...

set_camera_to_follow(pos_x as float, pos_y as float, pos_z as float, ang_x as float, ang_y as float, ang_z as float, max_distance as float, level_object as integer)

you'd only need to include ang_x and ang_z if it's in 3d-space (like a flight sim). if it's on the ground you just need to include angle_y

you could place a cube at XYZ. rotate it by the inputted angle. then, to view the object at XYZ from a little bit above, rotate cube by:

wrapvalue(object rotation x(cube) + 45.0), object rotation y(cube), object rotation z(cube)

then move it by the inputted "max_distance" value times negative one (so it goes backward).

get the new coordinates

use intersect object from XYZ to the new coordinates just obtained. this gives you the distance you should be away from XYZ. move the cube back to its original position and rotation, and move backwards by that amount (first subtract 1.0 or so units from that amount, so that the camera isn't inside a wall)

if there are multiple objects that you need to detect collision with, call the intersect object command with each one, and use the lowest value returned (unless they are all zero, in which case keep it at max_distance cuz that means no collision occured)
qwe
22
Years of Service
User Offline
Joined: 3rd Sep 2003
Location: place
Posted: 2nd Jul 2007 11:28
i just realized that this is in the DB classic forum and DBC doesnt have 'intersect object'

maybe someone else has another method
Latch
19
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 2nd Jul 2007 13:21
@helpme

Try setting the camera smooth to a much lower value than 100. In this example, I set it to 5.



Enjoy your day.

Login to post a reply

Server time is: 2026-07-06 18:58:24
Your offset time is: 2026-07-06 18:58:24