[Solved] Bullets are shooting in wrong position from enemies

Hello, i trying to learn gdevelop and i got some issues with enemies bullets. English is my second language so it´s little difficult to me, so im sorry if i have something wrong.
this is what i have thx to tutorial i did this but if i run the game it hapens this
The enemy have their vision but the bullet they spawn in another place. What i have wrong ? The bullets should appear in the enemies but they are above their heads and I specified the x and y points where they should spawn…

this is shooting code that i have


Nope, still same :disappointed: But another problem si that if i jump with my player bullets are moving with me …

Did you use anchor behavior for anything?
I seen it causing bullets moving with player

Next thing to check is zoom on layers
Different zoom on layers = different position of objects
BUT i think bullet extension works like bullet will be also spawned on same layer as object firing it

Can you add new scene add enemy to it and make it fire bullets constantly and add player to it and see if?
1 - if bullets move with player with jumping
2 - bullets spawn in wrong place
Also provide screenshot of your bullet point on your enemy object maybe you placed it wrong or something?

I added new scene and put there enemies and player. And it worked normaly as it should.So maybe it´s the layer…?I didn´t use the anchor but i use the zoom and center camera on my player …maybe they are the problem…

so i put platforms and deleted the zoom and put player in center and it works perfectly,
but i´m not sure if i wanted to put them back if it´s happened again. :sweat:

Camera following player should not cause such effect since i have it in all my projects and in none of them i have such problems

Zoom could be problem since that is 1st thing that happens to objects when they are on different layers with different zoom
They show in wrong location (actually in correct location but since zoom it just looks like that)

You could always change object size via events
If you need your enemies and/or bullets bigger or smaller

i used center camera on an object and makes the same problem so I think is both of them

i find another problems, is it okay to ask you if you can give me screenshots how you have it maybe thx to i find the problem and everthing will work

Here is my whole test project i use to test stuff
You can make UFOs shoot by jumping on button on the left
UFOs and player should be on same layer if i remember correctly
All events are grouped and properly named so you will have easier time finding what you need
Camera by default do not follow player to switch it to follow player you have button with camera in upper right
And it works perfectly fine without issues you describe

If you try it and it works but somehow still don’t work in your project
Then i would want you to upload your project like i did so i can investigate because it is impossible that it works for me but not for you

thank you so much :smiling_face: I will find my mistakes and i will tell you if it worked

i cant run it bc isn´t my game so i cant :sweat_smile:

I tested tons of projects from other users and never had message or whatever that would tell me i can’t run it because it is not mine so wtf?

Look UFO spawners are on base layer so they spawn UFOs on base layer

Player obje3ct is also on base layer

When active this action is firing bullets from UFOs

And you can test it here
Hit red camera button in upper right for camera to follow player
Here is what you see on screenshots above
UFOs shoot down

Here i changed UFOs to shoot right instead of down

this is what they tell my if i try to run it.
The bullet right now bc there´s no zoom or camera center on object…but the enemies both of the spawn the bullet even that im next to just one enemy, funny is that i specified that is for each one.

I sent this project to many users and none ever told me about that message
So i see it for the 1st time
Can you upload your project so i can test it?
I logged out from my acc as you can see log in button in upper right
And i am perfectly able to load my project
Did you unzip it?

And now i am logged in and i still can open it without problem

yes but maybe bc i was logged it didn´t work

i hope it will work i will be happy to know what i had wrong :smiling_face:

This is only question i want to ask you
So if you gonna reply anything then for me most important thing is answer to this question
(You did nothing wrong there is no wrong answers here i will tell you why i ask after you answer so that knowledge do not affect your answer)
Why you put action
Display an authentication banner
In your events?

OK so simple answer is wrong LAYER
Bullets somehow spawn on base layer and not on layer where enemy is (which is player layer)
What i did is
I added that background image with moon i found in your assets and i noticed bullets do not show up (each new object dropped to the scene goes to base layer so i knew that background is on base layer
And that it have higher Z order than other objects so it was covering bullets)
Then i changed every single object platform/enemy/player etc to base layer
And everything was working just fine (bullets were visible and spawning next to enemies)

Then i reversed that to be back on player layer and i simply added action to change layer of your bullets to player layer
Which also made everything work just fine meaning bullets were spawning next to enemies like they should

So here was your problem

Now rest info what you gonna read below are just mine tips you can either use or ignore
Because i see you are doing a lot of mistakes i did when i started making games

  • Be consistent when you add something to your game like new object
    Do not leave it as newsprite1 newsprite2 or whatever
    Properly named it
    Also take some rules into your heart either you go WithFirstWordLetterCapital
    Or yougowithalllowercase
    Trust me above tips sound very basic but later on when you get far into making something it saves A LOT of time and searching and figuring what is what
  • In your player behavior you had topdown behavior where your game is platformer so you should remove topdown behavior
  • In left panel click create or search for new extensions and type in search bar remap

    You add that extension (behavior) to your player and now you can define any keys which you would want to use to move your player for example WASD + Space
  • Do not use simulate keypress unless you really need it for like gamepad or touch controls
    Since from above tip you have that behavior your player will move on it own by pressing said keys
    Now you only set animation when key pressed and if you add trigger once to conditions they will work just fine
  • I did this and it works perfectly fine

    To get “if one of these conditions is true” you add condition and in search bar type OR
  • You have for your enemy flipping animation action so why not use that for player?
    You could have only player walking right animation and simply flip it horizontally or not depending if left or right key is pressed setting animation to walk/run
    Then simply if left or right key is released set event to change animation to idle/standing and also flip it or not depending on which key it was

    And so you could delete all animation images for left side and waste lest time preparing animations
  • You forgot to check Loop in your player animation for run right
  • Add condition at beginning of the scene with action to maximize window set to yes

When you gonna preview your game you can simply move mouse to upper right corner without even looking if you are on X button and close it regardless
Since window will be maximized and you will be always on X button if you just move mouse far enough to upper right corner

I think that is all
Again please answer my question from beginning about authentication baner

About authentication banner i don´t know I think i forgot to deleted it was from the start i started to created that game. But I really want to thank you for helping me. I will take you tips and i will try to do my best :smiling_face:

1 Like