Dupletor
Member
[Solved]
I need to keep many fishes in a moving aquarium.
The Aquarium has a fish house in it. It has to be positioned in the Aquarium center, always.
For this, through the house, I track the aquarium position differentiation, and add it to each fish.
This code works if the aquarium has 1 fish, and the fish moves with the aquarium. However, for some reason, if it has 2 fish, each fish starts moving twice as fast, and I have no idea why.
[EDIT: SOLVED]
It was solved because I noticed every fish had one house, and the problem was not that there were multiple fish, but that there were multiple houses, all of them interfering with every fish.
Then I edited again because I found it was not a full solution.
But then I couldn't reproduce the problem and it solved itself.
Well... Sorry.
I need to keep many fishes in a moving aquarium.
The Aquarium has a fish house in it. It has to be positioned in the Aquarium center, always.
For this, through the house, I track the aquarium position differentiation, and add it to each fish.
Code:
diffx = x;
diffy = y;
x = Aquarium.x + Aquarium.sprite_width/2;
y = Aquarium.y + Aquarium.sprite_height/2;
diffx -= x;
diffy -= y;
with(Fish){
x -= other.diffx;
y -= other.diffy;
}
[EDIT: SOLVED]
It was solved because I noticed every fish had one house, and the problem was not that there were multiple fish, but that there were multiple houses, all of them interfering with every fish.
Then I edited again because I found it was not a full solution.
But then I couldn't reproduce the problem and it solved itself.
Well... Sorry.
Last edited: