Rotate object + move to object position

This forum is currently in read-only mode.
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • Hi i need help, i want to make behavior as on picture:

    <img src="http://www.ourupload.xf.cz/soubory/9767/c4e0570e95d0bbddff5bbe803c647231.png" border="0" />

    One object i copy to 10 pieces. All object have to rotate around planet and move to planet position. I do not know hot to. pls help me :/

  • Here you are:

    mediafire.com/file/74rcbjcsv1b9d9a/planetattraction.cap

    For tasks like this, sin and cos are your friends. The principle is as follows:

    1) Calculate the distance from the objects to the planet on creation (posRadius)

    2) Calculate the angle between the objects and the planet on creation (posAngle)

    3) On every tick

       - rotate planet by 'rotationspeed'

       - rotate 'posAngle' by 'rotationspeed'

       - set object's x to planet.X + cos('posAngle') * 'posRadius'

       - set object's y to planet.Y + sin('posAngle') * 'posRadius'

       - reduce 'posRadius'

    You can reduce 'posRadius' with a fixed value. I reduce it based on the object's size (smaller ones get attracted faster than bigger ones). If you don't want that behavior, just set object's 'factor' to 1 in event 2:

    replace

    -> attracted: Set 'factor' to .Width / 32 - 0.5

    with

    -> attracted: Set 'factor' to 1

    Set the strength of the planet's attraction with the pv 'force'.

  • There is a plugin around on the forums called Orbiter, if you give those red circles the behavior and then decrease the radius of their orbit around the planet, it will have the effect you want.

    Try using the forum search to find it since it was released a long time ago now.

  • How I'd love people to more often use events. It would help so much understanding what is going on with the objects :)

  • How I'd love people to more often use events. It would help so much understanding what is going on with the objects :)

    True, but plugins run raw C++.

  • Thx a lot but i need to set my positions, but i try it from this .cap when i will have got a problem with it i will write again ;)

  • I know for a fact that the Orbiter behaviour is perfect for this sort of task. I had a plane orbited by several evenly spaced thingies no problem. So just look into it.

  • No orbiter does not work right with this all things ;)

  • Well, in this case I use a for each loop to give the orbiting objects random behaviours - if you want specific behaviours you'll have to adjust them by hand for each object, but this seems to do pretty much what you explained in the initial post.

    Grab the cap here (needs the Orbiter behaviour).

  • Or you just do it with the two events and without the need of a behavior as I showed in my cap in my first post <img src="smileys/smiley17.gif" border="0" align="middle" />

  • That's just all this silly programmer talk again! <img src="smileys/smiley2.gif" border="0" align="middle" />

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Learn how to do this with trig, seriously, it's the most useful tool you'll have in making ANYTHING game related besides construct itself. this is possible in like 3 actions even less. if you want to do a complex behavior that needs trig in the future (there are tons) there might not be an "orbiter plugin" and you'll have no foundation if you always take a shortcut to learning and wind up having to learn what you skipped thinking you were saving time.

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