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 / Help with 3d World

Author
Message
JamesWalker101
14
Years of Service
User Offline
Joined: 14th Apr 2010
Location: England
Posted: 14th Apr 2010 14:15
I need Collisions -camera to walls. Here is my code:


Set Camera Range 1, 10000
Load Object "C:\Program Files\Cartography Shop\maps\My_Courtyard.x", 2
Make Camera 1
Do
Space=SpaceKey()
Shift=ShiftKey()
If Space=0
Control Camera using arrowkeys 1, 10, 3
Else
Control Camera using arrowkeys 1, 20, 5
EndIf
If Shift=1
Set Ambient light 100
Else
Set ambient light 25
EndIf



Loop
Hawkblood
14
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 14th Apr 2010 15:37
**** INDENT **** Things will get messy if you don't start indenting now.

You don't have a sync command.

As far as the collisions, there are plenty of ways to do collisions in DBP. Just do a search in the help and you will find the right commands. It seems your game will be a first-person view, so that's going to be easy for you to do collisions. If I remember correctly there are commands specifically for camera collisions (or I may be still feeling the after affects of last night)..... Seek and ye shall find.

If you don't find, let us know and I'm sure we will help.

The fastest code is the code never written.
gamerboots
15
Years of Service
User Offline
Joined: 8th Dec 2008
Location: USA
Posted: 15th Apr 2010 06:29
ok,
step by step,
you wiil have to use either math (getting the distance between the camera and objects) or the built in collision.
the first step is to get the current camera x,y,z positions and store them to variables. after this is you can place the camera in its new position and check for possible collision. If collision returns true , you then reposition the camera back to its original position using the stored variables. in the example code I'm storing only the x and z positions because the y remains constant and I am using object # 23 to test for collision (you can add the code to make the object number of your choice)

I think you can take it from here.

----------------
Gamerboots~
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 15th Apr 2010 18:38
Take a look at Sparky's collision system here:
http://forum.thegamecreators.com/?m=forum_view&t=74762&b=5

It comes with demos and is the best plugin for collision I've found here...

Tom0001
18
Years of Service
User Offline
Joined: 30th Dec 2005
Location:
Posted: 17th Apr 2010 10:27
You might as well just use the automatic camera collision and set it to sliding.
gamerboots
15
Years of Service
User Offline
Joined: 8th Dec 2008
Location: USA
Posted: 18th Apr 2010 08:21
tom do you happen to have some quick sample code you can add to the thread. I'm sure there are a lot of ways to do this and perhaps some ways would be better in certain situations than others.

----------------
Gamerboots~

Login to post a reply

Server time is: 2024-11-23 17:08:19
Your offset time is: 2024-11-23 17:08:19