hi all
I ran in to another problem with my program an need a hand. I'm trying to make the zombies do the following.
1. Move each zombies around the world randomly and not follow the player.
2. Zombie collision with the world so they don't walk off the world
3. Create a circle around the zombie so they know when to follow the player
object 11 is the world map
object 12 is the player
zombie: `zombie function
zomb=4 `number of zombies
zombf =0
for x=100 to 100+zomb+1
zombb# = SC_raycast(11,zombx#,zomby#,zombz#,zomb2x#,zomb2y#,zomb2z#,0)`gets the old and new positions
`of the zombie using raycasting if there is a collision with the world
IF zombb# `check if there is a collision
POSITION OBJECT x,zombx#,zomby#,zombz# `if there is move the zombie back.
ran=0
print x `print the zombie if collision
endif
if zomb2x# - zzx# =5 or zomb2y# - zzy# =5 or zomb2z# - zzz# =5 `if zombie comes within 5 of player chase him
zombf =1 `zombie chase
else
zombf=0`zombie doesn't chase
endif
zombx#=OBJECT POSITION X(x) `holds zombie old position
zombz#=OBJECT POSITION Z(x)
zomby#=OBJECT POSITION Y(x)
zombx=x `hold zombie
randomz#=rnd(8000) `random z
randomx#=rnd(8000) `random x
zzx# = object position x(12) `holds new position
zzy# = object position y(12)
zzz# = object position z(12)
if zombf =1 `if chase
point object zombx, zzx#, -1, zzz#`point zombie at player
MOVE OBJECT x, 10`move zombie
SET OBJECT SPEED x, 15`sets zombie animation speed
loop OBJECT x,0,20 `loops the animation
zomb2x#=OBJECT POSITION X(x) `holds zombie new position
zomb2z#=OBJECT POSITION Z(x)
zomb2y#=OBJECT POSITION Y(x)
SC_UpdateObject x `update collision
zomb#=SC_raycast(x,x2#,y2#,z2#,X#,Y#,Z#,0) ` if collision with player
IF zomb#
Print "game over"
Print "press mouse to end program"
`sync
` WAIT MOUSE
`End
endif
else
if ran = 0
point object x, randomx#, -1,randomz#`random movement
ran = 1 `stop random movement
endif
move object x,10 `move in random direction
set object speed x,15`sets animation speed
loop OBJECT x,0,20`loops animation
zomb2x#=OBJECT POSITION X(x) `holds zombie new position
zomb2z#=OBJECT POSITION Z(x)
zomb2y#=OBJECT POSITION Y(x)
SC_UpdateObject x `update collision
endif
next x
Sorry to ask so much its the last part of my first game.
Thank you so very much for your help.
I'll add something later on.