when I press the left mouse key I have this error : NxRay direction not valid: must be unit vector.
Help me please !!!
Here is the code:
Rem Project: Atom Engine
Rem Created: Thursday, September 24, 2009
Rem ***** Main Source File *****
sync on
sync rate 60
autocam off
phy start
ai start
set camera range 0.5, 30000
hide mouse
set display mode 1280,720,32
Fog On
global balasAct as integer
global balasMax as integer
load sound "AK74M\fire.wav",100
rem load images
load sound "sonidos\ambiente\incident.wav",123 : set sound volume 123,70 : loop sound 123
load image "bullethole.png", 178
hud=144 : load image "imagenes\hud\corrupt.dds",hud
rem load image "AK74M\AK74vweap_D2.DDS",2
load image "AK74vweap_COLOR.png",2
load image "AK74vweap_NRM.png",3
load image "AK74vweap_SPEC.png",4
Effect = E3D Load Effect( "efectos\fps creator\bumpcubereflectalpha\bumpcubereflectalpha.fx", 1 )
load object "AK74M\AK74_onside.X",10
rem Setup gun for player
lock object on 10
scale object 10,20,20,20
rotate object 10,180,270,90
position object 10,0.9,-0.8,3.7
disable object zdepth 10
set object light 10,1
Set Object Effect 10, Effect
rem Set camera
set camera range 1,10000
set ambient light 100
position camera 315.18,345,-745.316
rem Load Map
load object "bedroom.x",1
load object "bedroom_lm.x",2
rem set bump mapping on 1,1
ghost object on 2,1
rem position camera 335.18,340,-745.316
phy make rigid body static mesh 1
make light 1
position light 1,335.18,340,-745.316
rem create our box controller
make object box 30, 20, 50, 20
phy make box character controller 30, 315.18, 300, -745.316, 10, 150, 50, 1, 10.5, 45.0
AI Add Player 30
hide object 30
dim armas$(9)
armas$(1) = "Colt.45"
armas$(2) = "44 SPCL"
armas$(3) = "M9"
armas$(4) = "G18"
armas$(5) = "JSCS Breecher"
armas$(6) = "AK 47"
armas$(7) = "M16"
armas$(8) = "M107"
armas$(9) = "Plasma cannon"
rem our main loop
do
rem rotate and position the camera based on the box controller
position camera object position x ( 30 ), object position y ( 30 ) + 20, object position z ( 30 )
rotate camera object angle x ( 30 ), object angle y ( 30 ), object angle z ( 30 )
OldCamAngleY# = CameraAngleY#
OldCamAngleX# = CameraAngleX#
CameraAngleY# = wrapvalue ( CameraAngleY# + mousemovex ( ) * 0.4 )
CameraAngleX# = wrapvalue ( CameraAngleX# + mousemovey ( ) * 0.4 )
yrotate object 30, curveangle ( CameraAngleY#, OldCamAngleY#, 24 )
xrotate object 30, curveangle ( CameraAngleX#, OldCamAngleX#, 24 )
rem react to key presses and move the controller
key = 0
if keystate(17) = 1
key = 1
phy move character controller 30, 200.0
endif
if keystate(31) = 1
key = 1
phy move character controller 30, -200.0
endif
if key = 0
phy move character controller 30, 0.0
endif
rem update the simulation and screen
gosub controlShooting
gosub rayCollision
gosub hud
gosub armaAct
phy update
remstart
if counter >= 500
stimer = timer()+3000
id = createRagDoll(id,offset)
offset = offset + 20
if offset > 150
offset = 40
endif
counter = 0
endif
inc counter
remend
sync
loop
remstart
rem In addition, we must ensure the player is always at the center of the universe. To that end, when ever the player moves we must adjust the position of the sky and the 3D listener which represents the player in our game:
rem Player is always focal point of sky
rem position object SkyObj,camera position x(),camera position y(),camera position z()
rem Position listener at player for 3D sound
position listener camera position x(),camera position y(),camera position z()
rotate listener camera angle x(),camera angle y(),camera angle z()
remend
controlShooting:
if mouseclick()=1 and balasAct < 0
armaxpos# = object position x( 10 )
armaypos# = object position y( 10 )
armazpos# = object position z( 10 )
armaxrot# = object angle x ( 10 )
armayrot# = object angle y ( 10 )
armazrot# = object angle z ( 10 )
value = phy ray cast all shapes ( armaxpos#, armaypos#, armazpos#, armaxrot#, armayrot#, armazrot# )
endif
dec balasAct
return
rayCollision:
rayColl = phy get ray cast object()
if rayColl = 1
make object plain 150,image width (178),image height (178)
rayPointx = phy get ray cast hit point x ()
rayPointy = phy get ray cast hit point y ()
rayPointz = phy get ray cast hit point z ()
texture object 150,178
position object 150,rayPointx,rayPointy,rayPointz
endif
return
armaAct:
select tecla
do case
case 2:
armaAct$ = armas$(1)
endcase
case 3:
armaAct$ = armas$(2)
endcase
case 4:
armaAct$ = armas$(3)
endcase
case 5:
armaAct$ = armas$(4)
endcase
case 6:
armaAct$ = armas$(5)
endcase
case 7:
armaAct$ = armas$(6)
endcase
case 8:
armaAct$ = armas$(7)
endcase
case 9:
armaAct$ = armas$(8)
endcase
case 10:
armaAct$ = armas$(9)
endcase
endselect
if tecla = 2
armaAct$ = armas$(1)
endif
return
hud:
sprite 1,930,570,hud
set sprite alpha 1,150
set text font "verdana"
set text size 28
text 1030,600,"100"
set cursor 1100,350
print armaAct$
rem print tecla
return