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 / [help] Collision with Sparky, Need guidance.

Author
Message
vocebello
19
Years of Service
User Offline
Joined: 30th Dec 2004
Location: Toronto, Canada
Posted: 12th Mar 2009 05:08 Edited at: 12th Mar 2009 07:34
I have been able to detect collision between an object (character) and another object (world).

However, I have not been able to stop the character from walking through the walls. I've been looking through the forums for the past few hours, and still seem stumped. I have included my code so you may see how I'm detecting collision, in hopes that you may be able to assist me in determining what steps I should take.



Thank you in advance.

Andre Mourinho
J_C
17
Years of Service
User Offline
Joined: 9th Nov 2007
Location:
Posted: 12th Mar 2009 21:25
You need to set-up some float varables before you enter the loop to keep the position of your camera object oldX & oldZ

you then set these to the camera object position in your loop.
Now when you move and detect collision you must re-positon your
camera and object back to oldX & oldZ position.

This is what stops you going through the objects you hit.

but you should really look through the samples that came
with Sparkys collison.
vocebello
19
Years of Service
User Offline
Joined: 30th Dec 2004
Location: Toronto, Canada
Posted: 12th Mar 2009 23:09 Edited at: 12th Mar 2009 23:17
I've changed my code a bit,



However, I can't seem to use sparky's collision stuff. It doesn't stop me from going through walls. My code I altered with a sloppy fix. I bounce off the walls a small amount, and go through them if the x or z value is positive. Close, but not there.
I've tried sparky's tutorials and combing the forums. I'll continue to do that, but I feel like I'm not too far off, and its something I'm just not seeing. I took your advice on the oldX and oldZ position as you can see in my code.

Thanks J_C for your help! =)
vocebello
19
Years of Service
User Offline
Joined: 30th Dec 2004
Location: Toronto, Canada
Posted: 13th Mar 2009 00:02
With a little bit of your help, and determination, I was able to get it working. THANK YOU J_C for the little tip that head me in the right direction.

I've included my code in case anyone has the same problem I did!

J_C
17
Years of Service
User Offline
Joined: 9th Nov 2007
Location:
Posted: 13th Mar 2009 19:59
Congratulations! vocebello
you did it all yourself
your determination will take you far.

I am pleased you made the leap to Collision Slide commands.
By taking small steps we can all learn...
Enjoy your programing journey...

Login to post a reply

Server time is: 2024-11-25 17:42:41
Your offset time is: 2024-11-25 17:42:41