“Stop one of them” - which one?
For the direction, there is a condition “object is turned towards another”.
Ahh my bad sorry …I meant one of the instances… for example if there are Enemy1 id =1 and Enemy1 id=2
Thanks! i didnt thought about that! and i never used it before^^
Do I have to use “0” or “180” as angle?
i think I made it! What do you think about it? Does it looks correctly?
(I used “0” as angle)
I think it does what its supposed to do. Maybe to “good”^^. I will do some better gameplay tests Tomorrow, and keep you updated^^
Thanks for your Help
I have a new question… but …also to Collision with same Instance…
there are three "instances of the object “EnemySmall”…the 2nd and 3rd are close to eachother … the first a bit away… it works perfectly if I have “delete EnemySmall”…with each collision player lose 25 “playerHealth”…if i do it without “delete EnemySmall”… the 2nd and 3rd “count as one collision”… and player lose only 25 for both and not 50.
Do you have an idea why? greetings
try to do it with a “for each” event?
Hey thanks for your reply… Did you see the photo? I did … Or do you mean something else?
what should happen with the enemies after he collide with the player?
never mind. I should use a cooldown timer to all of your instances, because without a cooldown they substract PlayerHealth all the time. so, if you don’t want to delete them when they collide I think you need to use it. or you should push either the player itself or the enemies.
this is my screenshot with the cooldown timers.
You should remove the highlighted line (id variable) because it’s useless… and perhaps conflicting?
Thanks for you time
I removed it…still the same problem
Variable id of enemySmall = enemySmall.Variable(id)
Of course it is! That’s always true! (A is always equal to A).
Unfortunately in GDevelop you can not make this kind of comparisons between instances of the same object. It is one of the limitations of GDevelop. The program just simply doesn’t know which instance you want to compare to which instance and then which instance you want to manipulate, delete, change…etc If you continue on this path it is going to only generate bugs in your game.
The only reliable solution is to have an invisible collider object linked and moved with each instance and when you want to check collision, distance between instances of the same object, do it with this collider object and check if they are linked. So the logic looks something like this:
If enemySmall is in collision with enemySmallCollider
And enemySmall is NOT linked to enemySmallCollider (meaning it was colliding with an other enemy instance)
Then pick enemySmall linked to enemySmallCollder (pick the other enemy instance it was colliding with)
Then stop enemySmall (the one linked to the collider it was colliding with)
Or move enemySmall away from enemySmallCollider (the one it is not linked to the collider)
I don’t have time to explain this in more detail, but this is the basic idea.
The order of execution is very important so you get a reference to the right instances of enemySmall and enemySmallCollider.
You also need to look in to object linking if you don’t know what that is.
don’t worry… thanks! thats a very smart idea actually… i understand what you want to say…but i’ve trouble with recreating it:
(while testing, only one of “Tr1” and “Try2” are active)
can you see the mistake?
Instead of the inverted “take into account” which is kinda confusing, I would try:
EnemySmall is in collision with Collider
EnemySmall.Variable(id) =/= Collider.Variable(id).
Thanks! Works! I can tell them apart now!
But i’m struggling with, recognizing which direction they have… or if they are facing each other or not… I tried it, for example with:
Text variable Direction of EnemySmallCollider= EnemySmall.VariableString(Direction)
It doesn’t work… I checked it in the debugger mode…
There is a condition “object is turned towards another”, give it a try.
They get seperated always…, no matter which rotation towards they have
do you have an idea whey or how to fix it?
I don’t understand what you’re trying to achieve, so I can’t help specifically.
Regarding “no matter which rotation”, the condition “rotated towards” has an angle setting you can use to broaden/restrict the “field of view” of the “viewer”.
When you get stuck, the best is often to open a new scene as sandbox and try specifically the conditions and actions you want to use, on dummy objects. And when you understand how the events cooperate/work, go back to your project and try it.
I want to achieve, if one enemy, is in collision with in his instance/ or another, and they have the same direction, they shall separated, so they can’t go inside each other. Because sometimes it’s hard to see if its one enemy or two…
But, if they have different directions, or facing each other, they have to “pass each other” otherwise they blocking each other… I hope I explained it well🤔 otherwise i could make pictures, to make it clearlier🤔
Hmm i didn’t understand it completely sorry
I’m already doing it! But clearly a good advice!
Thanks for helping me out so far🙏🏾
Ah, it’s to avoid getting blocked… Maybe you could set up a hitbox like this to avoid blocks:
This is what field of view is:
The angle setting is for that.
If you choose 0, the target needs to be in the exact direction of the viewer object for the condition rotated towards to be validated. If you choose 120, it would need to be in the 120° angle shown above.