How do I continue circular motion from the spawn point?

  • I have been testing and playing with the possibilities of circular motion. I really appreciate all of the threads created on the subject. There are so many ways to create a circular orbit (using sine behaviors, math with radians, or rotations, angle, etc...), fun stuff. The one that has seemed to be the most flexible and fun to play with was posted by Aphrodite, and I hope it is ok that I use his capx with some minor modifications to ask this question.

    I would like to be able to spawn the orbiting item, and have it start orbiting from the original coordinates. Instead, currently the way that a new orbiting object seems to move is:

    1. On the first tick the object teleports from the original coordinates to a new spot

    2. Second tick and on, smooth circular movement

    Does anyone know what it would take for any newly created object to start the rotation from the original spawning coordinates? I have tried many modifications to the formula under the "every-tick" expression to no avail. The project has spawning on touch coordinates for ease of troubleshooting/testing

    delete the space in the address to get the link to work

    https:// 1drv.ms/u/s!ApB1qfswGRM7gSHA85aiIGt-xYKk

  • If you give the object two instance variables: radius and ang

    Then you can do this

    Moon: on created

    —- moon: set radius to distance(planet.x, planet.y, moon.x, moon.y)

    —- moon: set ang to angle(planet.x, planet.y, moon.x, moon.y)

    Every tick:

    —- moon: add 100*dt to ang

    —- moon: set position to planet

    —- moon: move self.radius pixels at self.ang degrees

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Thank you ROJOhound! it works flawlessly. I have a feeling that I could have tried 1000 other combinations of the original event setup and would not have arrived to this solution. I had not considered using move at an angle for example.

    For any one that might want to see the modified capx, here it is, just take off the space for the link to work

    https:// 1drv.ms/u/s!ApB1qfswGRM7gSL_OrwzxqZOus1J

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)