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 / Collision Not working

Author
Message
John H
Retired Moderator
22
Years of Service
User Offline
Joined: 14th Oct 2002
Location: Burlington, VT
Posted: 31st Mar 2003 02:17
OK now this is WEIRD I am trying to get my collision to work (yea I know, this isnt funny) but its not, and I feel noobish!

Here is my collision code (parts from the tut )

REM make our little guy
make object cylinder 8,50
make object collision box 8,-25,-25,-25,25,25,25,0

REM Set object 5 [The test collision building, no need for a large box, just want some stoppage]
Scale object 5,5000,5000,5000
Position Object 5,2925,770,2580
make object collision box 5,-100,-100,-100,100,100,100,0

do
.....
rem Store old positions for collision
oldposx#=object position x(8)
oldposy#=object position y(8)
oldposz#=object position z(8)

rem Get current object position
posx#=object position x(8)
posy#=object position y(8)
posz#=object position z(8)

rem Sliding collision with our object and other objects
position object 8,posx#,posy#,posz#
if object collision(8,0)>0
dec posx#,get object collision x()
dec posy#,get object collision y()
dec posz#,get object collision z()
endif
....
loop


So, do you notice any bugs? Please help! This needs doing or else our demo will be pushed back (and you dont want that, he he )

Thanks a mill,

RPGamer
Current - RPG: Eternal Destiny
http://www.halbrosproductions.netfirms.com
Dont ask those questions! Read the help files lazy! Oh ya, and Tat has a plugin for that!
John H
Retired Moderator
22
Years of Service
User Offline
Joined: 14th Oct 2002
Location: Burlington, VT
Posted: 31st Mar 2003 04:11
OK I have come to the conclusion that if object collision(8,0)>0 simply does not work. I know this because I ran

if object collision(8,0)>0 then end

and nothing worked. So, I have instead mapped out the coordianates of the corners of the object. Now, it does detect the collision, I just need help getting the collision to work.

Please help!

RPGamer

Current - RPG: Eternal Destiny
http://www.halbrosproductions.netfirms.com
Dont ask those questions! Read the help files lazy! Oh ya, and Tat has a plugin for that!
Dr DooMer
22
Years of Service
User Offline
Joined: 22nd Dec 2002
Location: United Kingdom
Posted: 31st Mar 2003 04:20
Hmm, from what I can see, it works.

I copied what you've provided into the tutorial and, after a bit of number fiddling, ran it. The cyclinder collided nicely with the cube that I provided it with.

Now then, I'm certainly no expert on sliding collision, as I've never used it before, but here's a potential problem I can see:

The object that the cylinder is to collide with, what dimensions is it? I used and unscaled cube of size 200,200,200 because that fitted in with the collision box. I might be wrong, but maybe the collision box doesn't scale with the object. That would mean that only a tiny bit inside the object that you use is a collision box, rather than the 200 scaled by the 5000.

Could you trim down your code a bit and post the whole thing here? Then I can take a look over it all and see if I can help more.

"I am a living, thinking entity who was created in the sea of information."
Mnemonix
22
Years of Service
User Offline
Joined: 2nd Dec 2002
Location: Skaro
Posted: 31st Mar 2003 04:39
It seems we are going to have a lot of trouble with collision throughout this project. There are many types we are going to use since their will be many types of environment and they will not (obviously) be matrix based. There is still so much to accomplish before we can release a tech demo. And the story that will be covered by the demo ends on a real cliffhanger. I think RPGamer and I are planning to do the demo right up to the first boss so u will be able to take on the Colan Mine Demon . But for now, just wait in Earnest for more screenys. Note that all editors which are produced by me for this project will be released as freeware once the project is complete. So look forward in Earnest to that to. And as for this bloody collision. Well

Im addicted to Proplus.
Current Project: Eternal Destiny by Halbros Productions
http://www.halbrosproductions.netfirms.com
John H
Retired Moderator
22
Years of Service
User Offline
Joined: 14th Oct 2002
Location: Burlington, VT
Posted: 31st Mar 2003 04:45
Yea its not the size of the collision box or else there would be some collision. I mean, there is NO collision at all Really need to get this working

RPGamer

Current - RPG: Eternal Destiny
http://www.halbrosproductions.netfirms.com
Dont ask those questions! Read the help files lazy! Oh ya, and Tat has a plugin for that!
indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 31st Mar 2003 06:27
try this example



indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 31st Mar 2003 06:28
oops forgot to delete the matrix also

John H
Retired Moderator
22
Years of Service
User Offline
Joined: 14th Oct 2002
Location: Burlington, VT
Posted: 31st Mar 2003 14:51
Yes Indi that does work. I think I have located the bug in our code. I am quite sure it is a repeating variable, because we wrote a separate program with collision, and it worked fine. We just have one problem, we cannot get our object to keep on the matrix and keep collision.

Load object "edhouse1render.x",1
scale object 1,5000,5000,5000
position object 1,1000,150,1000

make object sphere 6,50
set object collision to spheres 6

sync on
sync rate 30
do

ay#= object angle y(6)
if leftkey()=1 then yrotate object 6,wrapvalue(ay#-5)
if rightkey()=1 then yrotate object 6,wrapvalue(ay#+5)
if upkey()=1 then move object 6,10
if downkey()=1 then move object 6,-10

if object collision(6,0)>0 then position object 6,x#,y#,z#
x#= object position x(6)
y#= object position y(6)
z#= object position z(6)

camx#= newxvalue(x#,ay#-180,100)
camz#= newzvalue(z#,ay#-180,100)
position camera camx#,50,camz#
point camera x#,0,z#

set cursor 10,10
print screen fps()

sync
loop

That is our code so far. As you would think, everything works. The ball collides with our house. Our only problem is that we cannot figure out how to keep our ground height without losing our collision.

Please help, and thanks again,

RPGamer & Friends

Current - RPG: Eternal Destiny
http://www.halbrosproductions.netfirms.com
Dont ask those questions! Read the help files lazy! Oh ya, and Tat has a plugin for that!
John H
Retired Moderator
22
Years of Service
User Offline
Joined: 14th Oct 2002
Location: Burlington, VT
Posted: 31st Mar 2003 15:04
Ah ha! I got it For some reason its not working if I say

for o#= 1 to 5
if object collision(6,o#)>0 then position object 6,x#,y#,z#
x#= object position x(6)
y#= object position y(6)
z#= object position z(6)
next o#

But it works if I only have one object in there Now I got collision and ground height, just had to throw in some extra variables Woo hoo!

Thanks

RPGamer

Current - RPG: Eternal Destiny
http://www.halbrosproductions.netfirms.com
Dont ask those questions! Read the help files lazy! Oh ya, and Tat has a plugin for that!
Mnemonix
22
Years of Service
User Offline
Joined: 2nd Dec 2002
Location: Skaro
Posted: 31st Mar 2003 15:16
Well done. Now we can continue development of our tech demo

Im addicted to Proplus.
Current Project: Eternal Destiny by Halbros Productions
http://www.halbrosproductions.netfirms.com
koolaid
22
Years of Service
User Offline
Joined: 26th Jan 2003
Location: Cyberspace
Posted: 1st Apr 2003 05:16
rpgamer first time i saw you have a problem and needed help?
John H
Retired Moderator
22
Years of Service
User Offline
Joined: 14th Oct 2002
Location: Burlington, VT
Posted: 1st Apr 2003 05:22
Nope its fixed. I was just repeating a variable I am very embarrassed Cyall later

RPGamer

Current - RPG: Eternal Destiny
http://www.halbrosproductions.netfirms.com
Dont ask those questions! Read the help files lazy! Oh ya, and Tat has a plugin for that!

Login to post a reply

Server time is: 2025-05-17 09:47:54
Your offset time is: 2025-05-17 09:47:54