Hey guys,
I need a simple waypoint system to make patrol paths for the enemies in my next project, similar to the one in the fps example provided with Blitz 3d (\samples\si\fps\fps.bb). Only thing is, I don't understand the waypoint code :( Can somebody explain it to me?
In case you're to lazy to look it up ;) I pasted the relevant part of the code. Perhaps you can just comment the code so that it is easier to understand?
Thanks in advance,
Kungfista
P.S.: Other waypoint examples are also welcome!
I need a simple waypoint system to make patrol paths for the enemies in my next project, similar to the one in the fps example provided with Blitz 3d (\samples\si\fps\fps.bb). Only thing is, I don't understand the waypoint code :( Can somebody explain it to me?
In case you're to lazy to look it up ;) I pasted the relevant part of the code. Perhaps you can just comment the code so that it is easier to understand?
Thanks in advance,
Kungfista
P.S.: Other waypoint examples are also welcome!
; Gargoyle speed, yaw values Global garg_speed#=0.2,garg_yaw# Global node=2 ; Node gargoyle aims for Dim node_x(10) Dim node_y(10) Dim node_z(10) Dim node_n(10,3) Dim node_v(10) node_x(1)=390 ; x position of first node node_y(1)=160 ; y position of first node node_z(1)=50 ; z position of first node node_n(1,0)=1 ; no of connected nodes node_n(1,1)=2 ; no of the first connected node node_v(1)=1 ; visits to first node by gargoyle node_x(2)=390 ; x position of second node node_y(2)=160 ; y position of second node node_z(2)=190 ; z position of second node node_n(2,0)=2 ; no of connected nodes node_n(2,1)=3 ; no of the first connected node node_n(2,2)=1 ; no of the second connected node node_x(3)=210 ; etc node_y(3)=120 ; etc node_z(3)=190 ; etc node_n(3,0)=2 ; etc node_n(3,1)=4 ; etc node_n(3,2)=2 ; etc ;[...] Function GargPath() PointEntity gargoyle,target_piv dest_garg_yaw=EntityYaw(gargoyle) If dest_garg_yaw-garg_yaw>180 Then garg_yaw=garg_yaw+360 If dest_garg_yaw-garg_yaw<-180 Then garg_yaw=garg_yaw-360 garg_yaw=garg_yaw+((dest_garg_yaw-garg_yaw)/(5/garg_speed)) MoveEntity gargoyle,0,0,garg_speed RotateEntity gargoyle,0,garg_yaw,0 garg_x=EntityX(gargoyle) garg_y=EntityY(gargoyle) garg_z=EntityZ(gargoyle) If garg_x=node_x(node) If garg_y=node_y(node) If garg_z=node_z(node) least=1000000 node_v(node)=(MilliSecs()-old_time)/1000 For i=1 To node_n(node,0) nv=node_v(node_n(node,i)) If nv<least Then least=nv : lnode=i Next node=node_n(node,lnode) PositionEntity target_piv,node_x(node),node_y(node),node_z(node) EndIf EndIf EndIf End Function