1. Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

  2. LOOKING FOR A VERSION OF SKRIPT?

    You can always check out our Wiki for downloads and any other information about Skript!

Dismiss Notice
This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Solved Rotate an entity 360° around player?

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

Thread Status:
Not open for further replies.
  1. NewbyZ

    NewbyZ Member

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

     
  2. Best Answer:
    Post #14 by ShaneBee, Jul 30, 2017
  3. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220
  4. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220
  5. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    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
     
  6. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

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

    Moderator Resource Staff Supporter + Addon Developer

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

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220
    Yes, i want rotate like an orbit, anyone know how?:emoji_eyes:
     
  9. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

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

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    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
    4.         set {radius} to 10
    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
    10.             set {z} to sqrt(({radius}^2)-{x}^2)
    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:
    19.                 add 0.5 to {x}
    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):
    27.                     add 0.5 to {x}
    28.                     set {top_half_of_circle} to true
    29.                     set {bottom_half_of_circle} to false
    30.  
    31.             wait 1 tick
     
    • Like Like x 1
  11. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    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
    4.         set {radius} to 10
    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
    11.             set {z} to sqrt(({radius}^2)-{x}^2)
    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:
    18.                 add 0.5 to {x}
    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):
    26.                     add 0.5 to {x}
    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 :/
     
  12. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220
    so here's a picture of the path of the armorstand:
    2017-07-29_16.54.15.png

    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
     

    Attached Files:

    • Like Like x 1
  13. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220
    Why the global vars? just use the circle function from my sexy shapes script
     
    • Like Like x 1
  14. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    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 :emoji_thumbsup:
     
  15. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

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

    (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
    9.         set {_radius} to 1
    10.         set {_angle} to 20
    11.         set {_rotation} to 180
    12.         set {_current} to 0
    13.         while {circle} is true:
    14.             add {_angle} to {_current}
    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 ShaneBee, Jul 30, 2017
    Last edited by a moderator: Jul 30, 2017
  16. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220
  17. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

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

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220
    Hey that sounds familiar :emoji_stuck_out_tongue: hehe
    [​IMG]
     
  19. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220
    Is this reply for me? If so, you can mention me via @glowgrew
     
Thread Status:
Not open for further replies.

Share This Page

Loading...