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 / camera collision?

Author
Message
David iz cool
19
Years of Service
User Offline
Joined: 21st Sep 2005
Location: somewhere lol :P
Posted: 2nd Feb 2011 21:51
how do u code the camera to not go into your player or walls or the ground???
anyone have some code on this
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 3rd Feb 2011 12:08
Straight from the help files after searching for "Camera Collision":
Quote: "AUTOMATIC CAMERA COLLISION
This command will set the specified camera to automatic collision.

Syntax

AUTOMATIC CAMERA COLLISION Camera Number, Radius, Response

AUTOMATIC CAMERA COLLISION Camera Number, Radius, Response, Stand Ground Mode

Parameters

Camera Number

Integer
The camera number
Radius

Float
The cameras with automatic collision use a collision sphere of the specified radius
Response

Integer
If the response value is set to one, the new position backtracks to the last collision free position when a hit occurs. A value of zero adjusts position for sliding collision
Stand Ground Mode

Integer
If the stand ground mode value is set to one, the camera cannot be pushed by other objects. The default is zero, which allows the camera to be pushed around by other objects

Returns

This command does not return a value.

Description

Automatic collision takes over the task of adjusting the camera when it hits an object in the 3D scene. Cameras with automatic collision use a collision sphere of the specified radius. If the Response value is set to one, the new position backtracks to the last collision free position when a hit occurs. Spheres and boxes are solid objects, and so collision can only occur when they collide together. When an object is entirely within another object, even though the geometry is not touching, the collision is still valid as the larger object would be a solid construct. If the additional "Stand Ground Mode" value is set to one, the camera cannot be pushed by other objects. The default is zero, which allows the camera to be pushed around by other objects.

Example Code

sync on : sync rate 60 : hide mouse:cls 0
autocam off
set global collision on
ObjectNumber=1
SecondObject=2
make object sphere ObjectNumber,10
color object ObjectNumber,rgb(0,255,0)
position object ObjectNumber, 0,0,0
make object cone secondObject,10
xrotate object secondObject,90
fix object pivot secondObject
color object SecondObject,rgb(255,0,0)
position object SecondObject, 15,0,0
AUTOMATIC OBJECT COLLISION ObjectNumber,5,1
AUTOMATIC OBJECT COLLISION SecondObject,5,1
AUTOMATIC CAMERA COLLISION 0,40,1,0
while mouseclick()=0
set cursor 0,0
if leftkey()=1 then turn object left SecondObject,1
if rightkey()=1 then turn object right SecondObject,1
if upkey()=1 and OBJECT HIT(SecondObject,0)=0 then move object SecondObject,1
if downkey()=1 and OBJECT HIT(SecondObject,0)=0 then move object SecondObject,-1
if spacekey()=1 then move camera 0,1
if returnkey()=1 then position object SecondObject,15,0,0
if OBJECT COLLISION(SecondObject,0) then print "OBJECT COLLISION"
sync
endwhile
set global collision off
delete object ObjectNumber
delete object SecondObject
end

"


If you can't find an answer there then post a question here. It's probably why you didn't get a quicker response.

Login to post a reply

Server time is: 2024-11-23 03:42:27
Your offset time is: 2024-11-23 03:42:27