I have an issue with my first game in Gdevelop. I am making aTank shooter game with the following mechanics: Using WASD to drive and rotate the tank realistic (Got this working). The gun needs to rotate seperatly from the tank, and always aim at the position of the mouse. Now i actually got all of this working with little issue, except there is a very weird 90 degree offset to my gun in relation to my mous position (See screenshot). I tried adding a manuall offset to the code, but this only makes it buggy (e.g. “Rotate TankGun towards MouseX() -90;MouseY() -90 at speed 12deg/second”). I tried variations to this, but none seem to work. I also tried angle etc. but that was even worse. Any Idea on how to fix this?
PS:
I had the same issue with adding force to my tank hull to get it moving, and did actually fix it with the addition of -90. Do I have a weird core problem with my sprite? They are not rotate in both the source image or in the game
Hi, I am not sure if this is the reason for your problem but in your animation for the gun, is it pointing by default towards east (0°)? If not, you should change that.
Rotating it in the editor is not solving this problem. The easiest way is to change the angle of the gun sprite with a software of your choice and reimport it in your animation.
"Rotate TankGun towards MouseX() -90;MouseY() -90 at speed 12deg/second”
This won’t work. You’re taking 90 pixels off the x & y co-ordinates, not the angle.
@Drona has given you the right solution - rotate the image in a drawing package, so that the turret faces to the right.
The reason for this is that GDevelop has the angle 0 degrees facing right, and not up the screen. So when you rotate to the mouse, GDevelop rotates the turret image so that the right side (initially at 0 degrees) faces the mouse.
I tried it and it worked. For both the hull and the gun. Thank you. Simple but effective solution. A bit weird it works like that, but it’s fine once you know the engine works like that.