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 / keeping the player in a certain area

Author
Message
Mikeygd3
12
Years of Service
User Offline
Joined: 18th Dec 2013
Location:
Posted: 11th May 2014 02:56
i wanna know how to keep the player from moving out of area defined by x and z coordinates
Derek Darkly
14
Years of Service
User Offline
Joined: 22nd Sep 2011
Location: Whats Our Vector, Victor?
Posted: 11th May 2014 03:58 Edited at: 11th May 2014 04:09
I would do something like this:




It saves the old position every loop so if you go too far it puts you back in your last good spot.
Others may have something more efficient.

666GO†O666
MrValentine
AGK Backer
15
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 11th May 2014 11:04
Look at the internal Newton Physics ODE system and implement collision methods, or use a physics library such as Dark Physics or Dark Dynamix or that other collision thing never used it so forgot what it is called...

chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 11th May 2014 11:49
Hi there.

@Derek Darkly. I hope you don't mind, I made some arrangements to your snippet. In your code , the camera get stuck in borders , this is correct somehow, but if we want a sliding collision ,we can use:




Cheers.

I'm not a grumpy grandpa
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 11th May 2014 13:10
Neat.



Powered by Free Banners
Derek Darkly
14
Years of Service
User Offline
Joined: 22nd Sep 2011
Location: Whats Our Vector, Victor?
Posted: 11th May 2014 17:39
Excellent Chafari!

I couldn't turn at first, but then I realized you added mouse turning.

666GO†O666

Login to post a reply

Server time is: 2026-07-06 19:40:15
Your offset time is: 2026-07-06 19:40:15