Apply a force towards all instances of an object


I’m currently working on a little game about a dog in a car who travels between small planetoids, à la Mario Galaxy. It’s based on the “Object gravity” example.

Currently I’m trying to work out how I can have all instances of the “Planet” object applying force to the dog at the same time. I made a system before that worked but it used seperate duplicate objects for each planet which was a pain as I had to implement each one seperately.

The normal movement actions has “Add a force towards an object” but Physics 2.0 doesn’t. I’m currently using this script, but it seems to just pick one of the Planets and applies the force towards that one.

If anyone can help or has a better way to acheive this I’d really appreciate it!

Have you tried the “For Each” event type? That way you could say “For each Planet object” then “Apply to spaceguy a force…”

1 Like

Ah yeah that seems to be doing the trick, thank you!

1 Like