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 / Anyone help with coding swimming

Author
Message
Stevie
User Banned
Posted: 16th Aug 2004 10:37
I am trying to write some code so that when the player enter a depth of water - at firt he stays just on top of the water - bobbing up and down - and then when he goes to mobve the camera down using the moouse, and then the up key he goes into the water, rather than on top????

Any ideas how i could code this. Also i noticed that when i wanted the player camera to sit just below the water line - the image on the screen started to tear up - i wanted it to merge with the main camera - but i believe there is no way around this
indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 16th Aug 2004 13:16
if the water is a matrix you can detect the height and therefore place the character around the height of the matrix.

you want the player to be sunken the water a little so an offset of the character with 10% sticking out of the water would suffice.

the next part would involve a bobbing sequence which could be acheived with a sin or cos adjustment to this offset variable from the given matrix height.

the last aspect is when you want to swim down so you would have an inverted jump code that makes you float back to the top after swimming down which is an adjustment of the offset variable.

If no-one gives your an answer to a question you have asked, consider:- Is your question clear.- Did you ask nicely.- Are you showing any effort to solve the problem yourself
Stevie
User Banned
Posted: 16th Aug 2004 22:14
I am a little stuck as to actually code the swim routine - as when u press the up key in the world - obviously u move the z coord and move forward -but how would i do it so i acutally swimdown - would it as i imagine involve using the mouse - so when u use the mouse to look down and press up - u would acutally swim down????

I am not using a matrix but an bumped object for the water on a terrain. When i position the camera to close to the surface of the water - the object starts to disapear. Is a matrix different ? and doesnt start to disapear
indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 16th Aug 2004 23:48
u might need a set of swim keys or use the mouse.

set the waters object to have both faces culled so you can see it from both sides.

If no-one gives your an answer to a question you have asked, consider:- Is your question clear.- Did you ask nicely.- Are you showing any effort to solve the problem yourself
Stevie
User Banned
Posted: 16th Aug 2004 23:56
Thanks mate - didnt think of culling - yeah i could set aside different keys for swimming that would make sense
indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 17th Aug 2004 02:12
also intersect object would have to be used instead of the matrix detection if its a model

If no-one gives your an answer to a question you have asked, consider:- Is your question clear.- Did you ask nicely.- Are you showing any effort to solve the problem yourself
David T
Retired Moderator
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: England
Posted: 17th Aug 2004 02:25
He's using terrain.

Get 15 new commands, all the date / time commands left out of DBPro for free!
DOWNLOAD PLUGINS HERE: http://www.davidtattersall.me.uk/ and select "DarkBasic"

Login to post a reply

Server time is: 2025-06-12 11:12:36
Your offset time is: 2025-06-12 11:12:36