A strange thing happened to me. I have been able to make several enemies move using object variable Direction = “Left”. I used the text of the variable in conditions with the action of Add a Force (angle). It worked as expected. (The problem follows.)
However, when I attempt to create a third enemy sprite using the same code, and the same process, it will not move.
So, I copied the code of the working enemy. I replaced the sprite with the new enemy with the object variable Direction, “Left”. No movement.
Hi, there’s basically dozens of reasons why that might’ve happened, but the only way we’d know is by looking at your Events sheet. It would really help in solving your problem if you paste a screenshot of it!
I’m guessing it’s mostly typos when copy-pasting such as using Character1.X() instead of Character2.X in your formulas, or moving the wrong character.
Also, if those three characters use exact same actions, you can learn about Object Groups, so the code will repeat reliably for all three of them: http://wiki.compilgames.net/doku.php/gdevelop5/objects/base_object#object_groups
In this scenario, I was hoping to create two different Object Groups. One would have a slightly different angle of movement instead of the basic back and forth. Before I changed anything, I tested the movements.
The Enemy sprite works great (and another that I copied the same code from).
The Badbird sprite does not move at all. I’ve changed the conditions to test what is happening to a key pressed instead of Modify the Text of Variable. It does move then. The issue must be the connection between the condition and the action.
I tested another hypothesis. Am I not allowed to have more than 2 different sprites (not in a group) use the same text variables? Well, I tested my hypothesis by changing Badbird’s variable name from Direction to Move. No cigar.
I’m certain there is an easy fix, but I’m not getting it yet. Suggestions O’wise ones? Appreciate!
Thanks for the picture! The events are definitely identical in function (all use object variables, other than StickCount, which I assume is lives), so we might have to look somewhere else.
Is the BadBird placed directly in EnemyLeft or EnemyRight?
Does Badbird have any behaviours that Enemy group doesn’t?
Does Badbird have a default direction?
I hadn’t placed EnemyLeft or EnemyRight around Badbird since Enemy moves without them. Regardless, I tried it, and it moved! So, why would I have to put the EnemyRight on Badbird but not Enemy?
Both are global objects. Could it be that Enemy touches EnemyLeft in a different scene?
Appreciate the help. To answer your 2 other questions.
Same behaviors? (Yes, none).
Default direction for Badbird? (I assume we are talking about Object Variables. If so, yes. Badbird’s variable was Direction and “Left” as the text.)