How do I make retactable objects from inside a circle?

0 favourites
  • 3 posts
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • I'm looking for a mechanic where that has a object retract in and out, similar to don't touch the spikes game, but inside of a circle instead of a square.

    I'm looking for it to be a random set of objects to appear each time, but they can appear anwhere around the edges of a circle.

    Can anyone help with this mechanic?

  • If I understand you correctly, what you need is a way to spawn objects randomly spread on a circle?

    If so, this is what I would do:

    • Set a number variable to random(360) to get a random angle
    • Now, to the more complicated part: Getting the coordinates of the point on the circle using the angle we created before
    • Get the X coordinate with this calculation: [X coordinate of circle center] + cos(angle) * [circleRadius]
    • Get the Y coordinate with this calculation: [Y coordinate of circle center] - sin(angle) * [circleRadius]

    This should get you going.

    Here is an example .capx, in case you are stuck.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • randomly

    Thanks for the reply, I'll check this out.

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