So I’ve used Construct 3 and I was able to do in 5 minutes what I have not been able to do in a month in Gdev.
So I create an enemy sprite, and with the same enemy some are supposed to go left to right and others are supposed to go right to left. Think of the cars in the Frogger video game [some going left to right and others going right to left].
Seems simple enough but no matter what action or behavior I use, no matter what event I put the code in … it doesn’t work correctly. when new enemies are created the direction of every enemy is changed.
#1 - I tried using permanent force in an event…using an object variable [if “mydirection” = 0, then to use for going right]. that didn’t work
#2 - I tried adding the top-down behavior…but it appears even when I “select” the right enemies with the object variable…ALL enemies have their direction changed [even the enemies that are not “supposed to” be selected].
WHAT AM I DOING WRONG? Below are screen shots of 2 completely different attempts in different projects…neither worked].
Can someone in Gdev address the issue [via YouTube tutorial video or even a recoding of future version / bug fix of Gdev] the ability to easily selecting one [and ONLY ONE] instance of an object and ONLY CHANGING the object variable, the characteristics of that particular object and NOT EVERY SINGLE instance?
This is ridiculous. I was able to make this animation work in 5 minutes in Construct 3; I dont want to move back to that platform but all the features of Gdev are useless if you cannot do the super simple thing.
Can you share the events that you are creating the enemies and changing the variable “MyDirection”?
Thank you for getting back to me.
So, I am creating new objects in a sub-event, but with a create object command…shown below:
Can you please let me know what [or where] my mistake is?
So, your problem is:
I did some tests here based on your example. Look the events:
Variables of Enemy:
And the result:
As you can see in my example when new Enemies are created it don’t change the movement of the Enemies that is already in the scene.
In that your event…
…all your created Enemies will have the variable “MyDirection” = 0 because you have an last action changing it (and it will effect all your Enemys that created above that action). So, if you want to create Enemies with different variables I think I could use different subevents. Something like this:
But I don’t know why in your project all Enemies are changing the variables when you created some new Enemies, because I couldn’t reproduce it here.
Rasteriko’s got the right of it, mostly.
On your second event screenshot, when you use the “create object” action, it adds the newly created object to the internal “selected object instances” list for that specific event. So each successive action targeting that object will also target all of the instances in that event’s list. (In your screenshot, the final 2 actions will target all 3 objects created in the event as they’re all selected at this point.)
That is by design and expected behavior.
Your first event screenshot is probably the closest to correct, but I’d put it in a “ForEach Enemy” event.
Thank you for your help, but no matter what I do I cannot get it to work. Is there anyway I can send to you a copy of my Game.json file and you can see first-hand what is going on and why I get the error?
I’d be more than happy to send you my file for you to inspect it first hand.
Please let me know.
I really think something is wrong with Gdev event processing.
This is the code from a YouTube video you guys published on events and changing animation:
Now here is my code for changing animation…it does not work, the character animation never changes [but its X-location does change]
Something is happening with Gdev and it is not “triggering” codes when it has to [as in this posting example]…and then it is “triggering” for each and every single instance of an object ever created.
I dont know what else to do…these are super-simple things in game making: changing locations, animations, movement direction [left to right, etc.]…and to get bogged down on a compiler that is not running events is crazy.
I’ve done simply stuff with Construct 3 in less than 5 minutes and moved on to the “difficult” part of making games…but I have never been stuck for so long on such simple tasks.
Can you please…please… help?
I am willing to send all game.json files to you guys for review and feedback.
A few things of note that I’m seeing:
A: The events in that video and your events are not the same, so using them as a point of comparison really doesn’t apply in this case.
B: Whenever you change animations, you need something to ensure it’s only triggering once, otherwise it can happen every frame, and reset your animation to the first frame.
In the example you’re linking, they’re checking that the animation is a completely different animation and is fully finished. This will only occur once because they then change the animation (so the conditions never apply again).
However in your events, you are just checking for collision then moving the object back slightly. However your force is permanent, therefore it’ll still apply (and still move back into collision) which means it is likely occurring every frame.
This statement isn’t really important to the issue at hand. Construct is not Gdevelop, and GDevelop is not construct. The event sheets look similar in layout (and even in those cases it’s only minor), but how event logic operates are not 1:1 the same, and you cannot take the event action logic from Construct and apply it to GDevelop, or vice versa, without iussue. Game logic methods are relatively universal and will be fine, though.
If you post your project json, I will take a look. I will not change your logic/project for you (I don’t have availability for that kind of thing this week), but I can definitely say at a glance where issues may lie.
Just an idea. Does NewSprite have an animation named “Mine”? Is it spelled exactly the same way in both places. This includes capitalization. Also, beware of any spaces. With the online version, I’ve used autocomplete but unfortunately it always adds a space after the word. Not the same.
Thanks for the reply back, and before posting this example I had double and triple checked to insure the spelling [to include case-sensitive, spacing] were all correct. Below are the animations for the enemy sprite showing the names as they appear [and still not being triggered].
Thank you for your reply and your guidance and willingness to help. I am learning the different logic between the 2 compilers and as a new user I’m trying hard [without much success] to overcome that difference between the two platforms because I want to transition exclusively into Gdev.
A couple of points:
1- after the enemy object collides with the rightEdge sprite it does not move back a little way but rather all the way back to the other side of the screen [a manual screen wrap technique even though there is an extension to do that…I need to test “triggering” and do certain things the currently available extension does not to.
See for example the screen shot below:
Once the sprite collides with the rightEdge, it moves back to the opposite end of the screen and slightly off of the screen to “re-enter” the screen [kind of like the cars moving back and forth in Frogger video game].
2-after the collision, the sprite does in fact move all the way back, consistently and continuously [as intended]…but the animation is never [not even once] changed.
3-Please let me know how I can Post my Game.json project online so that you can review it. I dont know how to “share/upload” that file.
Lastly, thank you again for your time and effort on this matter. I appreciate it [and I’m sure others doing the migration from Construct over to Gdev will appreciate it…because you truly have a better compiler but it is different].
Thank you and looking forward to your reply.
I’d recommend somewhere you can delete the file afterwards, like google drive. Otherwise, somewhere like https://www.file.io
I just sent you a private message with the file location, hoping I did that correct.
Thank you for all your help.
Some things from a quick glance:
You did not make the changes recommended above, you are still applying your logic to multiple created instances based on how your events are set up.
The above event will set both instances of Enemy spawned in this event to whatever number is selected in the final “Choose Random Number” event.
You are setting your spawn variable to “Yes” by adding quotes in the variable editor, but checking for Yes (no quotes) in your events. Strings in the variable editor do not need quotes around them, since you’re already declaring them as strings.
For reference, the above variable string is different than what is being checked for in the below event.
Here’s how the variable in that above editor ends up in the debugger:
- A large number of events in your scene needs “trigger once” as a condition. Some won’t run into issues because you are resetting a timer, some shouldn’t have it because you want it to happen every frame, but you should still use it to build correct practices and avoid needless performance hits on events that aren’t supposed to happen every frame.
All of the above said, If you fix #1 and #2 above you will likely resolve your issue. Again, split up your create events entirely as subevents (or just do a “Repeat X” event as a subevent of your condition, maybe?), and fix your variables to match your events. (No quotes in the variable editor).
Sorry for the delayed response, SHR! This week has been complicated for me, but I noticed that @Silver-Streak is already giving you support related to your project. And that’s good because he certainly has a lot more knowledge than me to help you!
Cool thanks for the detailed feedback. Just got a chance to jump on the computer and saw your detailed reply. I will go ahead and make all the changes and hopefully it’ll work fine. I’ll post a final outcome on this tread about the results [hopefully it works].
Just one humble suggestion: if at all possible can Gdev incorporate consistent variable assignment so that if there is a string var then that var must always have its value inside quotes [not just in quotes in one place and without quotes somewhere else]? Just a suggestion, for what its worth.
No Problem, thanks for all the help you two provided. I just jumped on the computer and will implement the changes and hope we’ll be back in business in no time.
So I incorporated all the changes you mentioned; triple checked all my work and then I still got the same problem.
Gdev does not select the correct Sprites and instead changes the animation on all sprites.
I have sent you a private message with the file.io link for the new file with all the changes incorporated but with the same problem. Sorry
Your events are doing what they are supposed to now. The biggest issue I’m seeing is you’re using a collision check condition that targets the same object you’re going to spawn. Any collision check (even inverted) will add all objects involved to the object list that qualify. When checking normal collision, you’re likely going to narrow it down to 1 or 2 objects. With an inverted condition, what you’re saying is “pick all instances of A and B that aren’t in collision with each other”.
Removing your inverted collision checks give this:
Numerous spawns with different colors (I just threw in test sprites since you only gave the json file).
If you must use a collision check in the same event you’re going to spawn that same type of object, you should probably get the Object Picking Tools extension and use the “Unpick all instances” condition (of enemy) in your events:
Again, unique coloration and movement.
Here’s where I threw in the condition.
Aren’t event-sheets executed  every tick and  top-down?
If so, then how can a code at line 1 for example that checks for collision or inverted collision include objects that have not been created further down on the event sheet [say in line 8, for example]? I’m trying to understand the basics here because dynamically created objects and customizing them allows for replayable games [you dont play the same level twice]…however, despite my best efforts i’m having difficulty understanding the underlying logic implemented in Gdev.
I’ll add the community extension you’ve suggested, and the unpick action and see if that resolves everything. thanks again for helping you…you have invested so much time helping me and i appreciate it.