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.

Dark GDK / Object Collision Help

Author
Message
Timatron
14
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 14th Dec 2009 01:45
I was working on the collisions in my game, and I can't get it to work. I know whats happening but I don't know how to fix it. I have it so when the player collides with the cactus in the game, all movement is disabled, but then he cant move at all. If I put dbMoveObject(ID,-3); it works when the player is facing forward but when they're facing backwards it sends them through the cactus.

Here's my collision code

The "if (dbObjectCollision(74,103) == 0)" is when the player collides with the cactus. Thanks everybody! Any help is greatly appreciated.

-Tim
logicandchaos
15
Years of Service
User Offline
Joined: 22nd Sep 2009
Location:
Posted: 14th Dec 2009 16:58
hey i think your problem is that your obects are still touching, you have to move your player object when there is a collision

if(dbObjectCollision(74,103)==0){
//move player back from object
}
but then you have to know what direction you were going which you could use a varible to keep track of, or you could try:


logicandchaos
Hassan
15
Years of Service
User Offline
Joined: 4th May 2009
Location: <script> alert(1); </script>
Posted: 14th Dec 2009 18:33 Edited at: 14th Dec 2009 18:34
try this:


So, you move freely, and everytime you move you save the old location, and at the end you check if they're colliding, if so, go back to old position.

hope that helped

Timatron
14
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 14th Dec 2009 21:43
Thanks for the help guys, I used what both of you said and got it to work. I had to make an X, Y, and Z variable for when the two weren't colliding and then set the object back to them. Thanks!!!

-Tim

Login to post a reply

Server time is: 2024-11-20 07:40:31
Your offset time is: 2024-11-20 07:40:31