playMaker

Author Topic: 2d GameObject Orbitting a Moving enemy  (Read 817 times)

TheNecron

  • Playmaker Newbie
  • *
  • Posts: 17
2d GameObject Orbitting a Moving enemy
« on: July 19, 2019, 08:09:57 PM »
Hello, so I have a boss enemy GameObject that moves in a random direction every few seconds that I would like to attach "orbital defenses" to that are basically objects that rotate around the enemy and destroy projectiles. I have the   projectile destruction functioning, however I have immense difficulty in setting up the code for the circling. Notably the most common tricks of simply rotating the satellite around as a child of the enemy doesn't work with rigidbodies on the satellites and other suggestions with rotate have worked poorly as the satellites or the enemy themselves sprites rotate. Is there any simpler/easier/more efficient way to do orbital movement (similar to whats seen in the binding of isaac, but on a randomly moving enemy) or do i need to calculate the vector2 velocities for some sort of circle formula every frame and add my enemies vector2 velocities to that?

daniellogin

  • Full Member
  • ***
  • Posts: 215
Re: 2d GameObject Orbitting a Moving enemy
« Reply #1 on: July 20, 2019, 12:36:19 AM »
What about if the object has a 'core' that is centered on the object, but the actual visual satellite offset a bit, then apply torque to that core? So not doing add rotation, but the physics version of spinning the object.