#how do you go about projectiles that go through enemies but can hit every enemy only once?

12 messages · Page 1 of 1 (latest)

lime rapids
#

Ive always gone about it by enemies having structs that add the ids of the bullets, but i really dislike that system, any other ideas?

idle knot
#

reverse it. have a list of enemies a bullet in the bullet has hit don't damage them again if they're on the list

lime rapids
#

structs still the way to go?

idle knot
#

i'd use an array

opaque boltBOT
#

This function checks if the given value exists in the array, or in a part of it. It returns true if the value exists, or false if not.

Arguments
array: The array in which to look for the value
value: The value to look for in the array
offset:  The offset, or starting index, in the array. Setting a negative value will count from the end of the array. The starting index will then be array_length(array) + offset. See: Offset And Length
length:  The number of elements to traverse. A negative value will traverse the array backwards (i.e. in descending order of indices, e.g. 2, 1, 0 instead of 2, 3, 4). See: Offset And Length

idle knot
#
//create
hitlist = []

//Step
var enemy = instance_place(x,y, oEnemy)

if !array_contains(hitlist, enemy){
  enemy.hp -= 1 //or wahtever
  array_push(hitlist, enemy)
}
#

instance_place_list is the same idea, just loop through the list, add them to the hitlist array

lime rapids
#

kk tyvm

idle knot
#

btw

#

just as a design principle

#

you wanna have the fewer object check for the many object

1 player checks for walls, not 100 walls checking for the player (most walls won't be any where near the player)

1 bullet checks for enemies, not 100 enemies checking for a bullet (most of them won't find a bullet)

#

save on operations and less data to manage