Search found 5 matches

by Ceresaurs
Sat Dec 07, 2024 1:37 pm
Forum: Support and Development
Topic: All Enemies are deleted when one dies
Replies: 8
Views: 1508

Re: All Enemies are deleted when one dies

What I struggle with understanding is if "self" refers to the entire class of individual instances.

Also thank you for the response, I don't understand it entirely but I think it'll push me in the right direction!
by Ceresaurs
Sat Dec 07, 2024 9:04 am
Forum: Support and Development
Topic: All Enemies are deleted when one dies
Replies: 8
Views: 1508

Re: All Enemies are deleted when one dies

I originally had a conditional (after the for loop in the take damage function) in hopes that it would make it so that if the Enemy that calls the function is equal to the instance to run the code on the single enemy, but it never passes the check and I don't know why. Using the self keyword returns...
by Ceresaurs
Fri Dec 06, 2024 9:51 pm
Forum: Support and Development
Topic: All Enemies are deleted when one dies
Replies: 8
Views: 1508

Re: All Enemies are deleted when one dies

Should probably also include this as well: function Hitbox.beginContact_PlayerToEnemy(a,b,collision) for i,instance in ipairs(ActiveHitboxes) do if a == instance.physics.fixture or b == instance.physics.fixture then for v = 1, #ActiveEnemys do if a == ActiveEnemys[v].physics.fixture or b == ActiveEn...
by Ceresaurs
Fri Dec 06, 2024 5:43 pm
Forum: Support and Development
Topic: All Enemies are deleted when one dies
Replies: 8
Views: 1508

Re: All Enemies are deleted when one dies

function Enemy:checkRemove() for i, instance in ipairs(ActiveEnemys) do if instance.health <= 0 then instance.toBeRemoved = true end if instance.toBeRemoved == true then instance:remove() end end end function Enemy:remove() for i, instance in ipairs(ActiveEnemys) do if instance.health <= 0 then ins...
by Ceresaurs
Fri Dec 06, 2024 12:56 pm
Forum: Support and Development
Topic: All Enemies are deleted when one dies
Replies: 8
Views: 1508

All Enemies are deleted when one dies

Hi! I'm new to love2d and coding in general and only started a couple of months ago. I'm having an issue where attacking one enemy, and it taking damage and running the remove function ends up removing all enemies on screen. I've tried countless of different ways to approach this and I'm not sure if...