[Solved]Camera movement and shooting


  • Posts: 4
Hey all, so I've been trying to make a game where the character moves around the map shooting things. The camera is supposed to stay centered on the player and the player shoots wherever the player clicks their mouse. For some reason when ever I make the camera track the player, whether I'm using premade behavior or use an event, it throws off the shooting accuracy. It seems to behave as though I clicked either further up or down than I actually did.
I don't know why or what to do about it so an help would be greatly appreciated.
Let me know if I need to give more info, this is my first time using this forum.
Edit: turns out I needed to add x of camera to the x of the mouse then subtract x-center of self

« Last Edit: May 20, 2018, 12:46:54 pm by LivyLauren »


  • *
  • Posts: 2295
The 'x of mouse' and 'y of mouse' use screen coordinates, but you want scene coordinates.

To convert from screen coordinates to scene coordinates, add the x,y of camera to x,y of mouse.
To convert from scene coordinates to screen coordinates, subtract the x,y of camera from x,y of mouse.

The code block you need to do this is in Scenes -> View palette.


  • Posts: 4
I did that and it seemed to help a bit but there is still a problem with deflection.
Its like the game wants to shoot directly above, it deflects to the right when clicking left of the player character and deflects to the left when clicking right of the player.
This deflection also gets more extreme the closer the mouse is to the center of the camera/player.
If anybody needs to see my code let me know.


  • Posts: 1434
Maybe post a screeenshot of game or video link.. with debug draw turned on


  • Posts: 4
Can anybody help, I really have no idea why it wont shoot right.
Every shot is pulled slightly to the area directly above the player and as you move closer to the player the pull is stronger.


  • *
  • Posts: 1543
See attachment, this makes something goes towards the mouse (it's either that or you have to add the camera's position to the mouse's position). X of mouse minus X of camera is not a direction, so you won't get it working as you want that way.

« Last Edit: May 20, 2018, 01:18:32 pm by Luyren »