Добрый день. Сталкнулся с такой проблемой : Есть два типа Bot и Bot2
в каждом по 5 кубов. Каждый из них должен в зависимости от расстояния выбрать себе противника и реследовать его. Код выдаёт ошибку, подскажите что не так.
Вот код:
Global Player
Global Bot_entity
Global Bot2_entity
Const TPlayer=1
Const TBot=2
Const TBot2=3
Type Bot
Field Bot_entity
Field target_
End Type
Type Bot2
Field Bot2_entity
Field target2_
End Type
Graphics3D 800,600,16
SetBuffer BackBuffer()
Create_Player()
Create_World()
Create_Bot(x,y,z)
Create_Bot2(x,y,z)
Update_World_001()
While Not KeyDown(1)
Update_Player()
Update_Bot(x,y,z)
Update_Bot2(x,y,z)
UpdateWorld
RenderWorld
Flip
Wend
Function Create_World()
cam=CreateCamera()
PositionEntity cam,0,100,-8
CameraClsColor cam,255,255,255
RotateEntity cam,90,0,0
light=CreateLight()
TurnEntity light,70,70,0
pla=CreatePlane()
;trava=LoadTexture("trava.jpg")
;ScaleTexture trava,10,10
;EntityTexture pla,trava
End Function
Function Create_Player()
player=CreateSphere()
PositionEntity Player,10,1,10
EntityType Player,TPlayer
End Function
Function Create_Bot(x,y,z)
For i=0 To 4
p.Bot = New Bot
p\Bot_entity = CreateCube()
EntityColor p\Bot_entity,255,0,0
;PositionEntity p\bot_entity,x,1,z
PositionEntity p\Bot_entity,Rnd(-20,0),1,Rnd(-20,20)
EntityType p\Bot_entity,TBot
Next
End Function
Function Create_Bot2(x,y,z)
For i=0 To 4
p.Bot2 = New Bot2
p\Bot2_entity = CreateCube()
EntityColor p\Bot2_entity,0,255,0
PositionEntity p\Bot2_entity,Rnd(20,0),1,Rnd(-20,20)
EntityType p\Bot2_entity,TBot2
Next
End Function
Function Update_Player()
If KeyDown(200) MoveEntity Player,0,0,.2
If KeyDown(20

MoveEntity Player,0,0,-.2
If KeyDown(203) TurnEntity Player,0,3,0
If KeyDown(205) TurnEntity Player,0,-3,0
End Function
Function Update_World_001()
Collisions TPlayer,TBot,2,2
Collisions TBot,TPlayer,2,2
Collisions TBot,TBot2,2,2
Collisions TBot2,TBot1,2,2
End Function
Function Update_Bot(x,y,z)
For p.bot = Each bot
If EntityDistance (p\Bot_entity,p\Bot2_entity)<100 Then
p\target_=p\Bot2_entity
EndIf
speed#=.03
bex#=EntityX#(p\Bot2_entity)
bez#=EntityZ#(p\Bot2_entity)
bbx#=EntityX#(p\Bot_entity)
bbz#=EntityZ#(p\Bot_entity)
bcx#=bex#-bbx#
bcz#=bez#-bbz#
bcn#=Sqr(bcx*bcx+bcy*bcy+bcz*bcz)
bcx=bcx/bcn
bcy=bcy/bcn
bcz=bcz/bcn
AlignToVector p\Bot_entity,bcx,bcy,bcz,0,.01
MoveEntity p\Bot_entity,0,0,speed#
Next
;Next
End Function
Function Update_Bot2(x,y,z)
For p.bot2 = Each bot2
;MoveEntity p\Bot_entity,0,0,.1
Next
End Function