So, I’m new to gdevelop and to programming in general, so excuse me if this is a noob mistake, but I just have no idea of what might be causing this issue.
What happens is that I programmed an object (physics 2.0) to move in the mouse direction with N force. That goes well. Then I made two variables that are set to X and Y values of the object after the movement happens, and a key pressing command that moves the char to the object’s position through the variables I set earlier.
The problem is, when I throw the object (say it lands in position A), then press the key to move the char after, it does nothing. If I throw the object again (landing in position B), then the char moves, but to the previous position (position A).
There’s the sequence of conditions and actions I set:
What might be causing this issue and how can I fix it?
Thank you in advance.
It won’t make a difference, but use CenterX() and CenterY(), not the bounding box position.
Do you have more than one BlueGem in the scene?
No no, only one BlueGem. I’ll try what you suggested, thank you.
I doubt it’ll make a difference. Is there anywhere else you use those variables?
No other place. Do you think it could have anything to do with the BlueGem physics 2.0 configurations? Dinamic, ball, density 3, angular damping 1, all else is as standard. The character does not have the physics 2.0 behavior, though.
The Physics settings shouldn’t make a difference.
I’ve replicated your code, and it works fine for me :
That won’t help you immediately, but it indicates you’re doing, or have done, something else to affect the position of the char object.
Can you provide a screen snip of more of your events?
This is all I have going for the game now, no more scenes or events.
Ok, this has got me stumped. The way the code reads it should be fine.
Can you try exiting GDevelop, and then starting it up again?
Hey! Fixed the problem. By changing the action that sets the blink variables (instead of being the W pressing, now its the S pressing), it worked just fine. This is the new configuration:
Found another problem though. When the ball is thrown to the left it kinda inverts the path. I point the mouse, lets say, X10 and Y10, the ball tries to move downwards. When I point downwards (X10, Y500), the ball moves upwards ‘-’ Made two text boxes so I could track the values of the mouse position, and it seems to be working as intended. Do you have any idea of what’s happening? Thank you again.
Do you mean the mouse is at position 10,10, or you are 10 pixels left and 10 pixels up from the centre of the ball? If the latter, where have you specified the point of the force be applied?
What are your physics settings for BlueGem? Can you provide a screen snip of that?
I was talking about the position of the mouse actually. Just tried to use the BlueGem center as a point to apply the force and it didn’t move at all lol
Those are the BlueGem physics (it’s configured as Dynamic with the “can sleep” box checked, just couldn’t get it all on the same print):
Do you want the gem to drop down? If not, set it’s gravity to 0.
Make sure the parameters are in a blue underlined box, not a red one (fix the red ones)…
The parameters were all right, but I think I found the problem. Added the point to apply the forces and changed forces applied (was using forces equal to the BlueGem’s density, now the forces are way bigger). It seems to be working fine. Now I think it’s just a question of adjusting the physics to find the perfect tune. Again, thank you for your help.