Help: my character shoots in the opposite direction when is moving [SOLVED]

Hi, I’m trying to do a plataform game and I wanted to make my character use a slingshot. I wanted to add an aim feature in which you can aim and shoot a stone to an enemy kinda like angry birds. It works but only when the character is still, when it moves the stone goes flying in the opposite direction.
I’m using physics 2 behaviour for both the character and the stone.
What can I do to make the stone fly the right way?
This are my events:

The sprites and variables that i’m using are in spanish but basically:
Aster is my character.
Resortera: slingshot
Piedra_proyectil: Stone_projectile
Piedra: Stone
Apuntar: Aim

EDIT: I solved it! The problem was that for some reason I wasn’t sharing the same points for all animations. I feel so dumb. Thank you so much to all the people who helped!

¿Any chances of looking the events you use to move the character? As far as I can see, I can’t spot any problem in the code.


Why are you applying a force on Apuntar based on the position of Piedra_poyectil? The aiming will not be correct because of this, and when the Piedra_Proyectil is created, it won’t be firing where you are aiming.

If there is one thing that we’ve learned is that having both a platformer and physics 2 behavior on the player usually creates some… anomalies further down the road. Try switching to full physics character and discard the platformer behavior events. (hence why Lshift para correr does not work) You need to impose the speed limit through the physics 2 events.

I did that following a youtube tutorial, but they wanted to move the character so in my case I change it to Piedra_Proyectil because that what I wanted to move. Should I change Piedra_Proyectil with something else?

Ok, I’ll be changing that too. thank u

Si es un poco confuso el ver ambos tipos de movimiento en un solo evento. Simulas que se presiona a la izquierda, por lo que supongo que tienes el movimiento de plataforma, y aplicas además una fuerza, como si fuera un objeto físico. En mi pobre opinión es un poco redundante.

Trata de dejar tu personaje con el movimiento básico de plataformas, deja de aplicarle la fuerza, y prueba el código de correr, espero que funcione con eso.

No creo que el nombre de Piedra_Proyectil sea el problema, es posible, que al aplicar la fuerza al punto de origen (tu personaje), anule la fuerza que aplicas a la piedra (Al menos recuerdo haber visto un experimento de física en el que disparaban una bala de cañón desde un auto en movimiento, que iba a la misma velocidad que saldría la bala, pero en sentido inverso, y la bala terminaba solo cayendo, sin movimiento horizontal)
Para comprobar, si caminas a la izquierda, y apuntas a la derecha (en caso que sea posible) ¿El proyectil sale disparado? ¿Sale disparado cuando caminas a la derecha y apuntas a la derecha?

Esas pruebas podrían ayudar a dar con la respuesta. Mucha suerte.

Yes it is a problem - Piedra_Proyectil may not exist, or be somewhere else on the screen. The force magnitude will be incorrect, and quite possibly in the wrong direction.

Yes, for that one line (where you apply force to Apuntar) change it to Apuntar. You are applying the force to Apuntar in the direction from Apuntar to the mouse. It makes no sense otherwise.

I don’t think that will happen here - piedra is not under the control of the player a they move. It’s created and is stationary. There are no forces working on it when it is created. GDevelop does not know it’s coming from a moving object.

I haven’t used forces so I was doing a wild guess, hence the tests I asked later, point to one side and shoot toward the same side, and point toward a side and shoot to the other.

If I follow the logic as intended, Aputar (Aim) is a kind of sight (+) that moves towards the mouse pointer when you keep the left button press, but moving toward it with a delay and just to a certain distance.

For me, what the events do is, while you keep the left button hold, move the aim helping sight to a position, when you release the button, the real projectil gets the force based on relative mouse position.

It is totally posible I am reading it wrong, of course.

Ya entendí de donde vino la confusión, al principio estaba usando un comportamiento de plataforma para el personaje, pero después lo cambie a physics 2 y al parecer me olvide de sacar esa linea. Ahora ya la saque, prefiero trabajar con Physics 2 porque también quiero que el personaje mueva cajas.

Excelente. Espero que también se haya corregido el problema con las piedras, que me quedé con la duda si ya había funcionado.