# Solved Rotate an entity 360° around player?

Discussion in 'Skript' started by NewbyZ, Jul 29, 2017.

Not open for further replies.
1. ### NewbyZ Member

Joined:
Jan 26, 2017
Messages:
75
2
What would be the math operation to spawn an armor stand and rotate (teleport) it 360° around the player?

#1
Post #14 by ShaneBee, Jul 30, 2017

Joined:
Sep 7, 2017
Messages:
2,184
220
#2

Joined:
Sep 7, 2017
Messages:
2,184
220
#3
5. ### ShaneBee ModeratorResource StaffSupporter +Addon Developer

Joined:
Sep 7, 2017
Messages:
2,184
220
this guys just want "Realisitc" rotate, Ever 1 ticks or 10 ticks or what ever, 1x roatet around, He can just look the code, Its simple. he should:

Code (Skript):
1. add "{Rotation:360f}" to nbt of target entity

#4
6. ### ShaneBee ModeratorResource StaffSupporter +Addon Developer

Joined:
Sep 7, 2017
Messages:
2,184
220
idk man, I'm pretty sure he wan't the armour stand to rotate around the player, kinda like an orbit.

#5
• Like x 1
• Friendly x 1
7. ### ShaneBee ModeratorResource StaffSupporter +Addon Developer

Joined:
Sep 7, 2017
Messages:
2,184
220
Oh... right... well... its maybe little Hard.

#6
8. ### ShaneBee ModeratorResource StaffSupporter +Addon Developer

Joined:
Sep 7, 2017
Messages:
2,184
220
Yes, i want rotate like an orbit, anyone know how?

#7
9. ### ShaneBee ModeratorResource StaffSupporter +Addon Developer

Joined:
Sep 7, 2017
Messages:
2,184
220
I think using Vectos may get you what you want, but I haven't messed with the a lot.

#8
10. ### ShaneBee ModeratorResource StaffSupporter +Addon Developer

Joined:
Sep 7, 2017
Messages:
2,184
220
this what i came up with based on y = +/- sqrt(r^2 - x^2)

its not terrible but the armor stands dont get deleted fast enough so you can sometimes see a few at a time.

hopefully someone can find a way to improve this or make it simpler
Code (Skript):
1. command /orbit:
2.     trigger:
3.         set {x} to 0
5.         set {top_half_of_circle} to true
6.         set {orbiting} to true
7.         while {orbiting} is true:
8.             set {circle_center} to player's location
9.             delete last spawned armor stand
11.             if {bottom_half_of_circle} is true:
12.                 set {z} to {z} * -1
13.             set {loc} to location at ({circle_center}'s x-coord + {x}), ({circle_center}'s y-coord + 1), ({circle_center}'s z-coord + {z})
14.             set block at {loc} to armor stand
15.             spawn an armor stand at {loc}
16.             add "{NoGravity:1}" to nbt of last spawned armor stand
17.
18.             if {top_half_of_circle} is true:
20.                 if {x} is greater than {radius}:
21.                     remove 0.5 from {x}
22.                     set {bottom_half_of_circle} to true
23.                     set {top_half_of_circle} to false
24.             else if {bottom_half_of_circle} is true:
25.                 remove 0.5 from {x}
26.                 if {x} is less than ({radius} * -1):
28.                     set {top_half_of_circle} to true
29.                     set {bottom_half_of_circle} to false
30.
31.             wait 1 tick

#9
• Like x 1
11. ### ShaneBee ModeratorResource StaffSupporter +Addon Developer

Joined:
Sep 7, 2017
Messages:
2,184
220
Thank you, it comes close to what I'm looking for, but is there any way to make it always go at the same speed?

Code (Skript):
1. command /orbit:
2.     trigger:
3.         set {x} to 0
5.         set {top_half_of_circle} to true
6.         set {orbiting} to true
7.         spawn an armor stand at player's location
8.         set {_a} to spawned armor stand
9.         while {orbiting} is true:
10.             set {circle_center} to player's location
12.             if {bottom_half_of_circle} is true:
13.                 set {z} to {z} * -1
14.             set {loc} to location at ({circle_center}'s x-coord + {x}), ({circle_center}'s y-coord + 1), ({circle_center}'s z-coord + {z})
15.             teleport {_a} to {loc}
16.             add "{NoGravity:1}" to nbt of {_a}
17.             if {top_half_of_circle} is true:
19.                 if {x} is greater than {radius}:
20.                     remove 0.5 from {x}
21.                     set {bottom_half_of_circle} to true
22.                     set {top_half_of_circle} to false
23.             else if {bottom_half_of_circle} is true:
24.                 remove 0.5 from {x}
25.                 if {x} is less than ({radius} * -1):
27.                     set {top_half_of_circle} to true
28.                     set {bottom_half_of_circle} to false
29.
30.             wait 1 tick
with teleport look smooth now, But it goes slow and then fast, constantly :/

#10
12. ### ShaneBee ModeratorResource StaffSupporter +Addon Developer

Joined:
Sep 7, 2017
Messages:
2,184
220
so here's a picture of the path of the armorstand:

as you can see it jumps at those points (i have no idea why) which would make it go faster at those parts. also becuase minecraft is blocky, the z-coord output will often land on the same block more than once in a row, more times at certain points and less at others which would also affect the speed.

maybe adjusting how much is removed/added to {x} would fix this but we might have to use a different method

File size:
1 MB
Views:
189
#11
• Like x 1
13. ### ShaneBee ModeratorResource StaffSupporter +Addon Developer

Joined:
Sep 7, 2017
Messages:
2,184
220
Why the global vars? just use the circle function from my sexy shapes script

#12
• Like x 1
14. ### ShaneBee ModeratorResource StaffSupporter +Addon Developer

Joined:
Sep 7, 2017
Messages:
2,184
220
it was an example so i didnt bother reaching all the way up on my keyboard to hit the underscore button.

Sweet, didnt know you had a circle function

#13
15. ### ShaneBee ModeratorResource StaffSupporter +Addon Developer

Joined:
Sep 7, 2017
Messages:
2,184
220
Done, thanks

(Final result, maybe useful for someone)

Code (Skript):
1. command /circle:
2.     permission: o.o
3.     trigger:
4.         spawn an armor stand at player's location
5.         set {_a} to spawned armor stand
6.         set gravity of {_a} to false
7.         set {circle} to true
8.         set {_l} to player's location
10.         set {_angle} to 20
11.         set {_rotation} to 180
12.         set {_current} to 0
13.         while {circle} is true:
15.             set {_l} to {_location}
16.             add ((cos ({_rotation} / 180) * 3.14159265358979323846) * ((cos (({_current} / 180) * 3.14159265358979323846)) * {_radius})) to x-loc of {_l}
17.             add (sin ({_rotation} / 180) * 3.14159265358979323846) * ((cos (({_current} / 180) * 3.14159265358979323846)) * {_radius}) to y-loc of {_l}
18.             add (sin (({_current} / 180) * 3.14159265358979323846)) * {_radius} to z-loc of {_l}
19.             teleport {_a} to {_l}
20.             wait 1 tick

#14
Last edited by a moderator: Jul 30, 2017

Joined:
Sep 7, 2017
Messages:
2,184
220
17. ### ShaneBee ModeratorResource StaffSupporter +Addon Developer

Joined:
Sep 7, 2017
Messages:
2,184
220
read better? he want like "Orbit" and not In same position and spinning

#16
18. ### ShaneBee ModeratorResource StaffSupporter +Addon Developer

Joined:
Sep 7, 2017
Messages:
2,184
220
Hey that sounds familiar hehe

#17
19. ### ShaneBee ModeratorResource StaffSupporter +Addon Developer

Joined:
Sep 7, 2017
Messages:
2,184
220
Is this reply for me? If so, you can mention me via @glowgrew

#18
Not open for further replies.