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 / keep walking through the matrix

Author
Message
Chief Engineer
21
Years of Service
User Offline
Joined: 26th Feb 2003
Location: United States
Posted: 3rd Mar 2003 06:59
hey again, got a new problem that i'm having trouble working out. i'll probably need to get that new DB book so i can quit bugging you people. i have high outer mountains on my matrix and i don't want the camera to go higher than 42000. so i set up my code to keep my Y height value below that, and that works fine. it stays below my 42000 height limit. the problem is that when i get that high, the camera walks straight through the matrix. i know that it has something to do with the x and z values, but i've looked everywhere for a solution. i've probably overlooked something so i was hoping someone could show me the light here.

rem store object angle
CameraAngleY#=Camera Angle Y()

rem control input for camera
if upkey()=1
Xtest# = newxvalue(X#,CameraAngleY#,20)
Ztest# = newzvalue(Z#,CameraAngleY#,20)
move camera 12
if sound playing(1)=0 then play sound 1
endif

if downkey()=1
Xtest# = newxvalue(X#,wrapvalue(CameraAngleY#),20)
Ztest# = newzvalue(Z#,wrapvalue(CameraAngleY#),20)
move camera -6
if sound playing(1)=0 then play sound 1
endif

rem running control
if shiftkey()=1
Xtest# = newxvalue(X#,CameraAngleY#,20)
Ztest# = newzvalue(Z#,CameraAngleY#,20)
move camera 30
if sound playing(3)=0 then play sound 3
endif


rem mouse control for camera
position mouse 320,240
cx#=wrapvalue(cx#+mousemovey() )
cy#=wrapvalue(cy#+mousemovex() )
cz#=wrapvalue(cz#+mousemovez() )

Rem Rotate camera
if cx#>270
if cx#-270 > 90 then cx#=270
else
if cx# > 90 and cx#-27042000
X# = camera position x()
Y# = 41999
Z# = camera position z()
endif


if Y#
Chief Engineer
21
Years of Service
User Offline
Joined: 26th Feb 2003
Location: United States
Posted: 3rd Mar 2003 07:00


my last post screwed up. once again, thanx in advance. you guys have thus far been a big help to this noob.
GCEclipse
22
Years of Service
User Offline
Joined: 23rd Sep 2002
Location: United Kingdom
Posted: 3rd Mar 2003 11:15
Hi,

I think your problem lies in the fact that you are moving the camera BEFORE checking for the height then when you get to checking the height is above 42000 all you are saying is move the camera to where it already is but at the height you want. That code would not bar access to sections of the matrix above 42000 it would merely ensure that the camera stays below it.

How I would do it (and I think its a fairly common method) is before you do anything create 3 vars OLDX# OLDY# OLDZ# and set them to the cameras position:

OLDX#=CAMERA POSITION X()

THEN, when you check for the height, if it is wrong you position the camera at the old values.

if Y# >42000
X# = OLDX#
Y# = OLDY#
Z# = OLDZ#
endif

Chief Engineer
21
Years of Service
User Offline
Joined: 26th Feb 2003
Location: United States
Posted: 4th Mar 2003 06:09
thanx, took a while but i got it to work. i also had to re-write my camera look commands so that i could walk back down the mountains without getting stuck at the height limit. thanx for the help.
GCEclipse
22
Years of Service
User Offline
Joined: 23rd Sep 2002
Location: United Kingdom
Posted: 5th Mar 2003 01:40

Login to post a reply

Server time is: 2024-11-24 03:23:01
Your offset time is: 2024-11-24 03:23:01