@Cash Curtis II said
Quote: "An AI entity will never walk through an obstacle"
yeah, but I mean sliding collision for the player entity, plus, it would also be useful to achieve other things...
-Edit: on top of that, I'm sure 2D can be a faster solution than 3D collisions, for many reasons
edit: see the image attached, showing that entities fire through each others, users must use some other collision techniques to prevent this...
http://forum.thegamecreators.com/xt/xt_apollo_pic.php?i=1679744 -(screenshot from "Sound Demo.exe") - here below is the source of this darkAI demo:
remstart
*
* Sounds
*
* -2 Enemies that will investigate any sounds within range.
* -IF the player is NOT found they will RETURN TO their positions
*
* -Compiled with Version 6.1
*
remend
SYNC ON : SYNC RATE 0 : AUTOCAM OFF
SET TEXT FONT "Verdana" : SET TEXT SIZE 14
rem creates the AI system
AI START
rem sets the global radius, all entities will assumed to be this size
AI SET RADIUS 2.5
MakeBackground()
MakeLevel()
DIM shootTimer(3) AS FLOAT
rem entity template
MAKE OBJECT CONE 1,5
XROTATE OBJECT 1,90
FIX OBJECT PIVOT 1
MAKE MESH FROM OBJECT 1,1
DELETE OBJECT 1
rem attack template
MAKE OBJECT PLAIN 1,0.3,1,1
XROTATE OBJECT 1,90
FIX OBJECT PIVOT 1
MAKE MESH FROM OBJECT 2,1
DELETE OBJECT 1
MakeColorImage(10,1,RGB(255,0,0))
rem make 2 enemies
FOR i = 2 TO 3
MAKE OBJECT i,1,0
POSITION OBJECT i,(i-2)*40 - 20,2.5,15
TEXTURE OBJECT i,10
MAKE OBJECT i+1000,2,10
SET OBJECT LIGHT i+1000,0
HIDE OBJECT i+1000
rem add them to the enemy team and set their speed (in units per second)
AI ADD ENEMY i
AI SET ENTITY SPEED i,10.0
AI SET ENTITY VIEW ARC i,90,170
AI SET ENTITY VIEW RANGE i,80
AI SET ENTITY HEARING RANGE i,80
AI SET ENTITY CAN STRAFE i,0
AI SET ENTITY STANCE i,1
AI Set Entity Can Search i,0
NEXT i
rem make player
MAKE OBJECT SPHERE 1,5
POSITION OBJECT 1,20,2.5,-40
AI ADD PLAYER 1
POSITION CAMERA 0,100,-30 : POINT CAMERA 0,0,-5
currtime# = TIMER()
lasttime# = currtime#
AI DEBUG SHOW SOUNDS 5
DO
currtime# = TIMER()
speed# = 0.06*(currtime# - lasttime#)
lasttime# = currtime#
IF UPKEY()=1 THEN MOVE OBJECT 1,speed#
IF DOWNKEY()=1 THEN MOVE OBJECT 1,-speed#
IF LEFTKEY()=1 THEN MOVE OBJECT LEFT 1,speed#
IF RIGHTKEY()=1 THEN MOVE OBJECT RIGHT 1,speed#
rem lowest priority sound (0)
IF SPACEKEY()=1 THEN AI CREATE SOUND OBJECT POSITION X(1),OBJECT POSITION Z(1),0,1
rem higher priority sound (11)
IF RETURNKEY()=1 THEN AI CREATE SOUND OBJECT POSITION X(1),OBJECT POSITION Z(1),11,1
rem handle debugging output
IF KEYSTATE(2)=1 AND ptimer<TIMER()
ptimer = TIMER()+300
pMode = 1-pMode
IF ( pMode=0 ) THEN AI DEBUG HIDE PATHS ELSE AI DEBUG SHOW PATHS 2.5
ENDIF
IF KEYSTATE(3)=1 AND btimer<TIMER()
btimer = TIMER()+300
bMode = 1-bMode
IF ( bMode=0 ) THEN AI DEBUG HIDE OBSTACLE BOUNDS 0 ELSE AI DEBUG SHOW OBSTACLE BOUNDS 0,2.5
ENDIF
IF KEYSTATE(4)=1 AND vtimer<TIMER()
vtimer = TIMER()+300
vMode = 1-vMode
IF ( vMode=0 ) THEN AI DEBUG HIDE VIEW ARCS ELSE AI DEBUG SHOW VIEW ARCS 2.5
ENDIF
IF KEYSTATE(5)=1 AND stimer<TIMER()
stimer = TIMER()+300
sMode = 1-sMode
IF ( sMode=0 ) THEN AI DEBUG HIDE SOUNDS ELSE AI DEBUG SHOW SOUNDS 5
ENDIF
IF ( KEYSTATE(59)=1 AND f1Timer<TIMER() )
f1Timer = TIMER()+300
F1Pressed=1-F1Pressed
ENDIF
IF ( F1Pressed )
rem display info
SET CURSOR 0,0
PRINT "Use Arrow Keys To Move, Press Space To Make A Sound"
PRINT "Press Enter To Make A High Priority Sound"
PRINT
PRINT "Debug Controls:"
PRINT "[1] Show Entity Paths"
PRINT "[2] Show Obstacle Bounds"
PRINT "[3] Show Entity View Arcs And Hearing"
PRINT "[4] Show Sounds"
PRINT
PRINT "FPS: ";SCREEN FPS()
ELSE
CENTER TEXT SCREEN WIDTH()/2, 30, "-- Press F1 For Help --"
ENDIF
rem hide attack lines
FOR i=1001 TO 1003
IF OBJECT EXIST(i) AND shootTimer(i-1000)<70 THEN HIDE OBJECT i
NEXT i
rem Call this command every sync to update entity AI state
AI UPDATE
FOR i = 2 TO 3
IF AI ENTITY EXIST(i)=1
IF AI GET ENTITY CAN FIRE(i) AND shootTimer(i)<=0
tx# = AI GET ENTITY TARGET X(i)
tz# = AI GET ENTITY TARGET Z(i)
x# = OBJECT POSITION X(i)
z# = OBJECT POSITION Z(i)
dx# = ( x# + tx# ) / 2.0
dz# = ( z# + tz# ) / 2.0
dist# = SQRT ( (tx#-x#)*(tx#-x#) + (tz#-z#)*(tz#-z#) )
ang# = ACOS ( (tz#-z#) / dist# )
IF ( (tx#-x#) < 0 ) THEN ang# = 360 - ang#
POSITION OBJECT i+1000,dx#,2.5,dz#
YROTATE OBJECT i+1000,ang#+0.1
SCALE OBJECT i+1000,100,100,100*dist#
SHOW OBJECT i+1000
shootTimer(i)=100
AI CREATE SOUND x#,z#,1,1
ENDIF
ENDIF
IF shootTimer(i)>0 THEN shootTimer(i) = shootTimer(i)-(speed#*3)
NEXT i
SYNC
LOOP
FUNCTION MakeBackground()
LOAD IMAGE "stripe5.png",1
LOAD IMAGE "stripe6.png",2
rem create the background object
MAKE OBJECT SPHERE 99,400,48,48
TEXTURE OBJECT 99,1
SCALE OBJECT TEXTURE 99,6,6
SET OBJECT CULL 99,0
SET OBJECT LIGHT 99,0
ROTATE OBJECT 99,0,0,90
rem add the logo across the bottom
LOAD IMAGE "logo.png", 100000
SPRITE 1, 0, SCREEN HEIGHT() - 60, 100000
ENDFUNCTION
FUNCTION MakeLevel()
rem make floor
MAKE OBJECT BOX 100,100,1,100
POSITION OBJECT 100,0,-0.5,0
TEXTURE OBJECT 100,2
MAKE OBJECT BOX 101,1,10,30
POSITION OBJECT 101,-10,5,0
COLOR OBJECT 101,RGB(RND(200),RND(200),RND(200))
AI ADD STATIC OBSTACLE 101
MAKE OBJECT BOX 102,1,10,30
POSITION OBJECT 102,10,5,0
COLOR OBJECT 102,RGB(RND(200),RND(200),RND(200))
AI ADD STATIC OBSTACLE 102
MAKE OBJECT BOX 103,40,10,1
POSITION OBJECT 103,-30,5,-15
COLOR OBJECT 103,RGB(RND(200),RND(200),RND(200))
AI ADD STATIC OBSTACLE 103
MAKE OBJECT BOX 104,40,10,1
POSITION OBJECT 104,30,5,-15
COLOR OBJECT 104,RGB(RND(200),RND(200),RND(200))
AI ADD STATIC OBSTACLE 104
MAKE OBJECT BOX 105,30,10,1
POSITION OBJECT 105,0,5,-32
COLOR OBJECT 105,RGB(RND(200),RND(200),RND(200))
AI ADD STATIC OBSTACLE 105
rem make boundary obstacle, encloses the space to keep the entity in
AI START NEW OBSTACLE
rem add points in a anti-clockwise direction to create a boundary (use clockwise to create an obstacle)
AI ADD OBSTACLE VERTEX -50,-50
AI ADD OBSTACLE VERTEX 50,-50
AI ADD OBSTACLE VERTEX 50,50
AI ADD OBSTACLE VERTEX -50,50
rem finish creating our boundary
AI END NEW OBSTACLE 0,1
AI COMPLETE OBSTACLES
ENDFUNCTION
FUNCTION MakeColorImage(image,mem,color)
MAKE MEMBLOCK mem,16
WRITE MEMBLOCK DWORD mem,0,1
WRITE MEMBLOCK DWORD mem,4,1
WRITE MEMBLOCK DWORD mem,8,32
WRITE MEMBLOCK DWORD mem,12,color
MAKE IMAGE FROM MEMBLOCK image,mem
DELETE MEMBLOCK mem
ENDFUNCTION
please note that except for that, I'm ok with the plugin & still use it.
@Cash Curtis what do you think about that?:
Quote: "many users would like a function to suspend/resume DarkAI in order to achieve special things & effects like bullet time, time stop (freeze every movement)"
?
pascontent.