I have particles, with a velocity (x and y) per tick. I would like to to make my cursor a gravity force, so particles fly to the cursor's position.
How can I apply gravity (that is towards my cursor position) on my velocity (x and y)?
Just subtract the particle position from the cursor position to make the acceleration vector. Then multiply the norm with the gravity constant.
This computation actually doesn't calculates the gravity force, but the gravity acceleration (in Earth). If you want to get the real gravity force for a more general case you should attribute your cursor and particle with mass. However this system implies that you cursor should also be affected by the force and I'm assuming that it isn't your intention. Anyway, the equation for the force is