I am using a for loop with 360 iterations to create an array of vectors each containing a position in the outer edge of a circle. Here is the code in JavaScript:
var circleArray = [];
var radius = 10;
var degrees = 0;
for(var i = 0; i < 359; i++) {
var vector = {
x: radius*cos(degrees);
y: 1;
z: radius*sine(degrees);
}
circleArray.append(vector);
degrees += 1;
}
for(var i = 0; i < 359; i++) {
createEffect("All Players(All Teams)", "Orb", "Color(Red)", circleArray[i], 1, "None");
wait(0.1);
}
The problem is that it is not creating a full circle. When doing the same but with 36 iterations and degree step by 10, I almost get a full circle, but with 360 iteration i barely get a quarter of a circle. Am I missing a fundamental understanding in maths or is there a bug?
The math is actually correct on my papers. The issue might be the expected visual representation that a full Cirlce with Orbs as a trail in your second loop can’t be drawn, the reason is if you working on the Live server there is curretnly a Limit for Entities like Effects that can be created, the limit is 128 for effects and texts. So your 129th Orb won’t be created and rendered.
3 Likes
Hm okay, that makes sense. After experimenting with some numbers though it seems 30 iterations with 12 degrees difference per iteration will make a full circle with no overlaps. No idea why 36*10 doesn’t work.
You can even fine tune it by increasing the degree by 3 or 2 with each iteration so you create more Orbs and it looks more condense. but be aware of what will you do after the creation you won’t be able to create more effects then, or less, it requires to destroy the previous created effects at some point in your script, be advised heavy creation and destruction might increase the server load to its peak and your mode will crash. Also what do you mean or applies now for you with these you first wrote the following:
Then
So what applies? My assumption might be you tried to create a second circle for visualize debugging, to glimps of what might work now, after the first instead of replacing the first creation procedure. Ofc if the limit is reached the 36 * 10 would lokk not right or wouldn’t even be visible or working. And i also hope you didn’t apply the JavaScript syntax 1:1 to the Workshop :D. Lastly since the first for loop is just a ranged based operation, and not work in cooperation with an Array you can safely give the range from 0 to 360 so the counter becomes the more even 360 degree of a circle instead of 359 which is odd, maybe thats the core little issue why 36 * 10 may just looks weird.
2 Likes