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

Author
Message
jayceeDB
21
Years of Service
User Offline
Joined: 3rd Jul 2003
Location:
Posted: 11th Aug 2003 10:07
Hi,

When I use the Set Collision command for an object, and move the object, it still moves through the other objects.

Setting Collision doesn't actually stop one object from passing through another, does it?

How can I stop one object from passing through another? Is there some easy command that I'm missing? Or some function that has to be written?

Thanks,
john...
Mentor
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: United Kingdom
Posted: 11th Aug 2003 16:44
you check for the collision and then tell the program what to do if you hit the object, after all you might not want to stop, you might want to ring a bell or add to the score or explode the objects or make it sink into the ground or fly away or open a door elsewhere on the map or whatever you wanted to do in your program, so you have "object hit" and "object collision", these are different ways of testing for collisions, you could use it like this (psuedocode)

do
save old position
get next position from keypresses
if object hit(playernumber,wallnumber)=1 then position=old position
sync
loop

what happens is the object hit function returns 1 when the player hits the wall, so you get put back to where you where before you hit the wall, if you keep trying to go through the wall then you keep getting put back, so you seem to stop, (although the computer is actualy putting you at the wall and then back where came from over and over), if you wanted to test for a pickup, like a health bonus you do..

do
get next position from keypresses
if object hit(playernumber,lifebonusnumber)=1 then life=life+20:delete object lifebonusnumber
sync
loop

in this case you dont stop, you just get 20 added to the variable life and the object is deleted to stop you picking up more life from it, you could use code to test for the player hitting a door, that could make the door open, or it could only open if a variable like redkey=1, so then you could set the redkey to one when they player hits the redkey (wherever you put that on the level) and then open the door when the player hits it IF they had hit the redkey, easy yes?, hope thats some help.

Mentor.

Login to post a reply

Server time is: 2024-09-20 19:37:01
Your offset time is: 2024-09-20 19:37:01