Object Attraction
Описание | Как имитировать притяжение объектов друг к другу? |
---|---|
Область знаний | Биология, Информатика, Физика |
Область использования (ISTE) | Computational Thinker |
Возрастная категория | 8
|
Поясняющее видео | |
Близкие рецепту понятия | Преследовать другого агента |
Среды и средства для приготовления рецепта: | Scratch, Snap!, StarLogo Nova |
In Object Attraction two or more objects are attracted to each other; or are pulling on each other. This can also be referred to as gravity.
Elliptical Orbit Method
One way to make one object attracted to another object is to make a sprite "Orbit" around the other object. This method is always 100% accurate and will automatically move when the object that it is being rotated about moves. Here is a script that creates an elliptical orbit:
Remember that this script goes in the object that is being rotated.
One example of the elliptical orbit method can be found here.
Velocity Method
Another method is to have a sprite change its velocity automatically based on its position. This method is very inaccurate however it can be very useful if your creating a game where you have to avoid multiple sprites. The Following scripts will be placed into the item that is "following" another sprite:
One example of the velocity method can be seen here.
Trigonometric Method
Direct Movement Method
This method although far more basic than the previous methods, can be very useful in certain situations. This method is very accurate and will move automatically with the sprite. Here is an example script that would be place in the sprite that is "following" the other sprite:
One example of the direct movement method can be seen here.
Wall Method
This method sort of has a fast wall attraction.