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 / Terrain collision

Author
Message
Wi1dcat Man
15
Years of Service
User Offline
Joined: 15th Feb 2009
Location: United States
Posted: 6th Mar 2009 04:16 Edited at: 6th Mar 2009 13:02
hello, I'm new to DB Pro, and I'm trying to make an rpg game, and i know it will take a while, but I really just want to know how to make collision. I have Sparky's Collision DLL, and I studied the sliding demo to try to make my object collide with the terrain, but it doesn't work.

The only thing I can think of wrong is I'm not doing it right, it's because my object is a cube, or because the surface I'm colliding with is a bmp map, and not a .x object.

Please help, I don't care if you give me code to help, or tell, but any help will be very appreciated

Thanks, Wildcat Man

Code:
Sixty Squares
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 6th Mar 2009 12:48 Edited at: 6th Mar 2009 12:51
There is a terrain example that comes with Sparky's Collision DLL which is relatively recent (I have v2.04b and it's in there, and it comes with v2.05 as well). Instead of using SC_SetupComplexObject try using sc_setupTerrainCollision .

Also, I don't see any collision code in the code you posted besides the SC_SetupComplexObject command. That command only sets your object up for collision-- you will need to check for collision in your loop. You will also need to setup up your cube object with the SC_SetupObject command.

Wi1dcat Man
15
Years of Service
User Offline
Joined: 15th Feb 2009
Location: United States
Posted: 7th Mar 2009 02:14
Hey Sixy Squares, thanks for the help, but I think i have v2.05, and it says sc_setupTerrainCollision isn't used anymore and to use sc_setComplexObject. Anyway, I have a small dbo map i can use instead of the terrain, but can someone explain to me how to make collision (for a third person type game)?

Thanks.
Wi1dcat Man
15
Years of Service
User Offline
Joined: 15th Feb 2009
Location: United States
Posted: 7th Mar 2009 04:12
Hey, I got my collision working, thanks to one of RUCCUS's posts, the only problem is everything is blue... I don't know if there's something in my code or what, but I've tried a few different maps, .Xs and .DBOs, I'll put a download to a .X map I got from a tutorial, I forgot who made it but I didn't.

If anyone can help, thanks.

Attachments

Login to view attachments
Wi1dcat Man
15
Years of Service
User Offline
Joined: 15th Feb 2009
Location: United States
Posted: 7th Mar 2009 04:14 Edited at: 7th Mar 2009 15:07
Here's the code, sorry



EDIT:

I figured out what was wrong, i had GHOST OBJECT ON 2, which made everything blue and clear, I deleted it and everything is fine now, just working on gravity.
Thanks again Sixty Squares.
chafari
Valued Member
18
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 9th Mar 2009 18:35
Hallo friends....there is an easy way to collide... (simulate collision) with the terrain or matrix.... and we just have to know the matrix or terrain heithe around us to decide to slide forcing the camera (player object )to go around or stop if not posible to go.

Have a look to this litle example.

Cheers.


[/code]
autocam off
sync on
ink rgb(0,100,0),1:box 0,0,50,50
ink rgb(0,200,0),1:box 10,10,40,40
ink rgb(0,130,0),0:set cursor 0,0
print
print "CHAFARI"
print "CHAFARI"
print "CHAFARI"
get image 1,0,0,50,50,1

`We make the terrain
`_______________________
make matrix 1,2000,2000,50,50
prepare matrix texture 1,1,1,1
randomize matrix 1,50
for i= 10 to 40
set matrix height 1,i+rnd(5),i+rnd(5),rnd(300)
next i
update matrix 1
`starting position
x#=300
z#=300
`________________________

do
//camera controls
if upkey()=1 then x#=newxvalue(x#,a#,0.3) : z#=newzvalue(z#,a#,0.3)
if downkey()=1 then x#=newxvalue(x#,a#,-0.3) : z#=newzvalue(z#,a#,-0.3)

if leftkey()=1 THEN x#=NEWXVALUE(x#,a#-90,0.3):z#=NEWZVALUE(z#,a#-90,0.3)
if rightkey()=1 THEN x#=NEWXVALUE(x#,a#-90,-0.3):z#=NEWZVALUE(z#,a#-90,-0.3)

a#=wrapvalue(a#+mousemovex()/2)
cam#=wrapvalue(cam#+mousemovey()/2)
y#=get ground height(1,x#,z#)+5

`camera limits
if cam#<=290 and cam#>180 then cam#=290
if cam#>=70 and cam#<180 then cam#=70
rotate camera cam#,a#,0

`we make sure the player walk around
`_____________________________________
xd#=get ground height(1,x#+30,z#)
xi#=get ground height(1,x#-30,z#)

zf#=get ground height(1,x#,z#+30)
zb#=get ground height(1,x#,z#-30)

if xd#>y#+20 then dec x#,0.3
if xi#>y#+20 then inc x#,0.3

if zf#>y#+20 then dec z#,0.3
if zb#>y#+20 then inc z#,0.3

position camera x#,y#,z#
`_____________________________________

sync
loop
[code]

oh my god

Login to post a reply

Server time is: 2024-09-28 02:26:48
Your offset time is: 2024-09-28 02:26:48