I'm making a game like "tower defense", but i have a problem that can't solve, I think i know what is the problem, but I don't know how to fix it.
It's a problem I have when I make the towers shoot the enemy when they are in their range of vision.
When there are many enemies and towers created on stage, the towers do not fire in order or all enemies.
I would appreciate much if someone helps me find a solution to my problem.
Yup, the problem is that you're not specifying instances of objects. When you don't specify, MMF will compare events to the last created instance. I won't waste your time with a long and complicated explanation on how to set things up, better programmers have already made wonderful examples on how to achieve that crucial basic of TD games;
I have downloaded and analyzed the example, but at move forward with the programming appear some problems (I do not want to go into details). The example is good only for a very basic tower defense game, but it becomes useless for more complex games.
I think it would be better for me if someone modified my example and fix this error, it would be for me the best way to understand based on the MFA file, because my English is bad and if someone gives me a long explanation I probably not understand much.
I'm sorry, I don't have the time to make your engine for you, it's a somewhat complicated procedure, plus the fact that you wouldn't know how it is set up, making for more problems in the future. What you need to do is this;
- Find a means to loop through every instance of the turret. The ForEach-extension or spreadvalue+fastloop is what you're going to want to use.
-When you have a way of going through every instance of the turret, you now need to check if any target is in range of the turret. And you can't just do an 'anonymous' check either, cause MMF will only check range for the last created instance in that case. You need to differentiate between instances.