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 Professional Discussion / object hit does nothing

Author
Message
falcon33
22
Years of Service
User Offline
Joined: 22nd Sep 2003
Location: none
Posted: 1st Apr 2010 13:46
i can't get collision detection to work even when i typed the examples from the book "hand on dark basic pro vol 2"
listing 40.2
the objects passes through with on collision detected

none
Dia
21
Years of Service
User Offline
Joined: 16th Jan 2005
Location:
Posted: 1st Apr 2010 16:36
give us an excerpt of your code and someone may be able to help you. (I dont have that book)

just remember that the OBJECT HIT command just returns a "1" if two objects are touching, it is up to YOU to determine what happens when they collide (i.e. If you want them to bounce, explode etc)

do a forum search for sliding collision for a couple of examples, although I think most people use sparky's for a lot of collision stuff these days (a little bit better than the native dbpro functions)

This is not the Sig you are looking for....
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 1st Apr 2010 23:25
Darkbasic detect collision, but don“t stop objects moving...you have to decide what the object must do once the collision is detected.

cheers.

I'm not a grumpy grandpa
falcon33
22
Years of Service
User Offline
Joined: 22nd Sep 2003
Location: none
Posted: 2nd Apr 2010 00:54
object_hit = OBJECT HIT(1,2)

if object_hit = 1
print "object hit"
endif


the "object hit" message do not appear even when both objects are inside each other.
so i tried examples from the book and there's did'nt work as well ??
i'm using the latest dbp 7.4

none
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 2nd Apr 2010 01:05
Try set object collision on

And if that doesn't work, make a collision box around both objects:



Also, it could be that you aren't looking close enough at that variable. Object hit() will only return a 1 once, then it will flip back to 0 until you pull the objects apart and put them back together. Then it will return a 1 again, and flip back to 0 etc...

If you want the function to always return a 1 while they are together, use object collision()

TheComet

chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 2nd Apr 2010 02:08
Hi there..

@falcon33
Instead of object hit, use object collision , and it works fine



cheers.

I'm not a grumpy grandpa
Sepnon
16
Years of Service
User Offline
Joined: 7th Feb 2010
Location: Brazil
Posted: 2nd Apr 2010 04:59
I think it's working, but it's just too fast
try this:



or try setting sync rate to 60
Attila
FPSC Reloaded TGC Backer
21
Years of Service
User Offline
Joined: 17th Aug 2004
Location:
Posted: 6th Apr 2010 14:27 Edited at: 6th Apr 2010 14:28
The problem seem to me that he check object 1 against 2 but the the result will be 2 because object 1 hits object no 2

id would be better to ask:

Login to post a reply

Server time is: 2026-07-26 15:31:48
Your offset time is: 2026-07-26 15:31:48