Going nuts with the enemies

Blitz3D Forums/Blitz3D Programming/Going nuts with the enemies

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

I haven't tested this code but I think you want something like this:

For x = 0 To 199
  If EntityInView(malomeshes(x),camera) Then
    active(x) = 1
  End If
Next

;movimiento de los malos
For x = 0 To 199

  If active(x)
    ; Calculate vector from enemy to player.
    vec_x# = EntityX(player,1) - EntityX(malomesh(x),1)
    vec_y# = EntityY(player,1) - EntityY(malomesh(x),1)
    vec_z# = EntityZ(player,1) - EntityZ(malomesh(x),1)
    
    ; Gradually align enemy to vector.
    AlignToVector malomeshes(x),vec_x,vec_y,vec_z,3,0.05
		
    ; Move enemy along vector.
    MoveEntity malomeshes(x),0,0,0.5
  End If

Next