Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Distance Code and Size Changing
- BizzareSnow
-
Scratcher
5 posts
Distance Code and Size Changing
When I change in distance, the size of my character changes, but I also want it to increase when the distance gets smaller. However, my characters change in size constantly as soon as it goes out of the camera range.
Please help and thank you!
https://scratch.mit.edu/projects/656351084/
(if you can, please reply some errors of my code and how to fix it)
Please help and thank you!
https://scratch.mit.edu/projects/656351084/
(if you can, please reply some errors of my code and how to fix it)
Last edited by BizzareSnow (March 8, 2022 20:26:13)
- Scratch-Minion
-
Scratcher
1000+ posts
Distance Code and Size Changing
If you assume the start distance is 100 for size 100, you can change the size to match the distance as below:
NB. You can test the above code by showing “distance” as a slider variable between 25 and 400 and while the project is running you just adjust the distance with the slider.
If you assume the start distance is 50 for sprite size 100, you can change the size to match the distance as below:
(You can use a start distance other than 50 if you want)
when green flag clicked
set [distance v] to [100]
set size to (100) %
forever
set size to ((100) / ((distance) / (100)) %
end
NB. You can test the above code by showing “distance” as a slider variable between 25 and 400 and while the project is running you just adjust the distance with the slider.
If you assume the start distance is 50 for sprite size 100, you can change the size to match the distance as below:
(You can use a start distance other than 50 if you want)
when green flag clicked
set [distance v] to [50]
set size to (100) %
forever
set size to ((100) / ((distance) / (50)) %
end
- Discussion Forums
- » Help with Scripts
-
» Distance Code and Size Changing
