2 Replies Latest reply on Nov 29, 2012 2:12 PM by prodigalmaster

    gravity help


      hi can some one help how do you make gravity around one point like a planet


      but if there were more than one that they would affect the gravity if that is not possible then


      just around one point which you can move around

        • 1. Re: gravity help
          FrostByte1995 Level 1

          what r u trying to make?  i have a complete code for it on a player with ground but thats all. if that what you need let me know.

          • 2. Re: gravity help
            prodigalmaster Level 2

            The following may not be clear and does not give you the exact code but im sure you can work it out with tutorials.


            Find the x and y distances from the point and make the x/y speed of the movieclip the x/y distance but divide it by say something like 20 so it doesnt get there instantly.


            This will work of both the point and the movieclip is moving, otherwise the movieclip will just go in a straight line to the point.


            I assume the point is another movieclip.


            You can apply the code to multiple movieclips where each movieclip has dynamic variables (values are unique to them) using a for loop and the movieclip names have this syntax:

            where i is the value of the for loop (iteration) - you may need to create multiple movieclips with a for loop first using the above syntax for naming them (then assign them the dynamic variables i.e.  _root["movieclipname"+i].xDist:Number;

            to create movieclips use the attachMovie() function.


            To compare multiple movieclips use a for loop within a for loop where the variable used is i for one and j for the nested... work it out. Then distance is like this:

            _root["movieclipname"+i].xDist = _root["movieclipname"+i]._x-_root["movieclipname"+j];

            for x distance.