Send objects away from touch event orgin

Hello!

I’m not sure where to put this one, so I put it in Newbie questions. I hope this discussion helps someone else!

I’d like to create a game where physics objects are pushed away from a touch event location. I know how to get the touch event location, but I don’t know how to push other objects away from the touch event.

For example, in the screenshot below, I’d like to be able to touch right below the grey circle to push the circle up. However, if I touch to the right of the circle, the circle should move left. Is there a way to push other physics objects away from a x, y location? The ideal solution is for the physics to push all objects away from 360 degrees around it.

(I know the screenshot is pretty simple, but I wanted to have something else to describe the situation.)

Screenshot%202015-09-30%2016.47.16.png

Like this?

https://www.youtube.com/watch?v=H4ROrXzokaA&feature=youtu.be

Code here: http://github.com/roaminggamer/RG_FreeStuff/raw/master/AskEd/2015/09/touchimpulse.zip

Uses my two new plugins (math2d and collision calculator).  Don’t forget to activate them before building for devices.

To activate plugins,

  1. Go the the links above.

  2. Click green free button.

  3. ‘Buy’ for free.

  4. Done.  Activated.

Wow! This is amazing stuff Ed! Seriously, great stuff. I’ve got an upcoming course that I’m building and I’d like to use this code. As long as I’m giving you credit, is it okay to use it? I won’t be shy about saying who this came from.

If anyone is reading this, you should support this guy at https://www.patreon.com/roaminggamer?ty=h. Even $1 a month will make a huge difference. I’m going to put money where my mouth is and commit to the patreon. This guy does some amazing stuff for the community. 

Feel free to use the code as you wish.  Once I put code out in my free stuff archive (http://github.com/roaminggamer/RG_FreeStuff/) you’re good to use it pretty much any way you want.  Credit is not required, but always appreciated.

Also, thank you for the Patreon plug, here and in the other thread.  I really appreciate it!

-Ed

Like this?

https://www.youtube.com/watch?v=H4ROrXzokaA&feature=youtu.be

Code here: http://github.com/roaminggamer/RG_FreeStuff/raw/master/AskEd/2015/09/touchimpulse.zip

Uses my two new plugins (math2d and collision calculator).  Don’t forget to activate them before building for devices.

To activate plugins,

  1. Go the the links above.

  2. Click green free button.

  3. ‘Buy’ for free.

  4. Done.  Activated.

Wow! This is amazing stuff Ed! Seriously, great stuff. I’ve got an upcoming course that I’m building and I’d like to use this code. As long as I’m giving you credit, is it okay to use it? I won’t be shy about saying who this came from.

If anyone is reading this, you should support this guy at https://www.patreon.com/roaminggamer?ty=h. Even $1 a month will make a huge difference. I’m going to put money where my mouth is and commit to the patreon. This guy does some amazing stuff for the community. 

Feel free to use the code as you wish.  Once I put code out in my free stuff archive (http://github.com/roaminggamer/RG_FreeStuff/) you’re good to use it pretty much any way you want.  Credit is not required, but always appreciated.

Also, thank you for the Patreon plug, here and in the other thread.  I really appreciate it!

-Ed