Repel actors on screen touch.


  • Posts: 134
Hi all,
Just trying to find my feet with the new iOS features. What I'd like is a few actors just sitting around and if you touch near one (say you press just to the right of the actor) it repels the actor away from where you are pressing on the screen until it's no longer within the range of where you pressed. Repelling faster if you press closer etc...

Any pointers on where to start?


  • *
  • Posts: 1961
You could have a look at 'Motions & Forces' in the Stencylpedia for some ideas about how to apply physics in Stencyl...
Visit - the only published book for learning Stencyl.


  • Posts: 16
In the 'Motions & Forces' article, I would recommend using

For the angle, instead of using 90 degrees use the angle between your actor position and the mouse position.

To figure that out you need to find the arctangent of the difference between the two points:

Don't forget to convert this to degrees because it returns a radian value.

For the force, you want it to be relative to the distance between the position of the actor and the position of the mouse.

I am not aware of a built-in way of calculating this but the formula is pretty easy:

Online Multiplayer Game for iOS:


  • Posts: 134
Thanks all, I'll give this a blast on Monday and feedback.


  • Posts: 134
Okay, I already feel pretty out of my depth on this one.

I suppose the first step is; while I understand how to apply something if I'm clicking directly ON an actor, I don't understand how to set up applying something if clicking NEAR an actor. I'm thinking I have to work out the relative value between mouse and actor but this needs to be a radius around the actor. Like so...

So Self X-Centre +20 is just working in a straight line. How do a create a circle around the actor that detects when the mouse is in it.