Solved Rotate an entity 360° around player?

  • 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!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Status
Not open for further replies.

NewbyZ

Member
Jan 26, 2017
75
2
0
25
What would be the math operation to spawn an armor stand and rotate (teleport) it 360° around the player?
 
That would just rotate an amour stand around itself, no?
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_language.skript:
add "{Rotation:360f}" to nbt of target entity
 
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_language.skript:
add "{Rotation:360f}" to nbt of target entity

around the player

idk man, I'm pretty sure he wan't the armour stand to rotate around the player, kinda like an orbit.
 
  • Like
Reactions: NewbyZ
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_language.skript:
command /orbit:
    trigger:
        set {x} to 0
        set {radius} to 10
        set {top_half_of_circle} to true
        set {orbiting} to true
        while {orbiting} is true:
            set {circle_center} to player's location
            delete last spawned armor stand
            set {z} to sqrt(({radius}^2)-{x}^2)
            if {bottom_half_of_circle} is true:
                set {z} to {z} * -1
            set {loc} to location at ({circle_center}'s x-coord + {x}), ({circle_center}'s y-coord + 1), ({circle_center}'s z-coord + {z})
            set block at {loc} to armor stand
            spawn an armor stand at {loc}
            add "{NoGravity:1}" to nbt of last spawned armor stand

            if {top_half_of_circle} is true:
                add 0.5 to {x}
                if {x} is greater than {radius}:
                    remove 0.5 from {x}
                    set {bottom_half_of_circle} to true
                    set {top_half_of_circle} to false
            else if {bottom_half_of_circle} is true:
                remove 0.5 from {x}
                if {x} is less than ({radius} * -1):
                    add 0.5 to {x}
                    set {top_half_of_circle} to true
                    set {bottom_half_of_circle} to false

            wait 1 tick
 
  • Like
Reactions: NewbyZ
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_language.skript:
command /orbit:
    trigger:
        set {x} to 0
        set {radius} to 10
        set {top_half_of_circle} to true
        set {orbiting} to true
        spawn an armor stand at player's location
        set {_a} to spawned armor stand
        while {orbiting} is true:
            set {circle_center} to player's location
            set {z} to sqrt(({radius}^2)-{x}^2)
            if {bottom_half_of_circle} is true:
                set {z} to {z} * -1
            set {loc} to location at ({circle_center}'s x-coord + {x}), ({circle_center}'s y-coord + 1), ({circle_center}'s z-coord + {z})
            teleport {_a} to {loc}
            add "{NoGravity:1}" to nbt of {_a}
            if {top_half_of_circle} is true:
                add 0.5 to {x}
                if {x} is greater than {radius}:
                    remove 0.5 from {x}
                    set {bottom_half_of_circle} to true
                    set {top_half_of_circle} to false
            else if {bottom_half_of_circle} is true:
                remove 0.5 from {x}
                if {x} is less than ({radius} * -1):
                    add 0.5 to {x}
                    set {top_half_of_circle} to true
                    set {bottom_half_of_circle} to false
 
            wait 1 tick

with teleport look smooth now, But it goes slow and then fast, constantly :/
 
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_language.skript:
command /orbit:
    trigger:
        set {x} to 0
        set {radius} to 10
        set {top_half_of_circle} to true
        set {orbiting} to true
        spawn an armor stand at player's location
        set {_a} to spawned armor stand
        while {orbiting} is true:
            set {circle_center} to player's location
            set {z} to sqrt(({radius}^2)-{x}^2)
            if {bottom_half_of_circle} is true:
                set {z} to {z} * -1
            set {loc} to location at ({circle_center}'s x-coord + {x}), ({circle_center}'s y-coord + 1), ({circle_center}'s z-coord + {z})
            teleport {_a} to {loc}
            add "{NoGravity:1}" to nbt of {_a}
            if {top_half_of_circle} is true:
                add 0.5 to {x}
                if {x} is greater than {radius}:
                    remove 0.5 from {x}
                    set {bottom_half_of_circle} to true
                    set {top_half_of_circle} to false
            else if {bottom_half_of_circle} is true:
                remove 0.5 from {x}
                if {x} is less than ({radius} * -1):
                    add 0.5 to {x}
                    set {top_half_of_circle} to true
                    set {bottom_half_of_circle} to false
 
            wait 1 tick

with teleport look smooth now, But it goes slow and then fast, constantly :/
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
 

Attachments

  • 2017-07-29_16.54.15.png
    2017-07-29_16.54.15.png
    1 MB · Views: 266
  • Like
Reactions: NewbyZ
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_language.skript:
command /orbit:
    trigger:
        set {x} to 0
        set {radius} to 10
        set {top_half_of_circle} to true
        set {orbiting} to true
        while {orbiting} is true:
            set {circle_center} to player's location
            delete last spawned armor stand
            set {z} to sqrt(({radius}^2)-{x}^2)
            if {bottom_half_of_circle} is true:
                set {z} to {z} * -1
            set {loc} to location at ({circle_center}'s x-coord + {x}), ({circle_center}'s y-coord + 1), ({circle_center}'s z-coord + {z})
            set block at {loc} to armor stand
            spawn an armor stand at {loc}
            add "{NoGravity:1}" to nbt of last spawned armor stand

            if {top_half_of_circle} is true:
                add 0.5 to {x}
                if {x} is greater than {radius}:
                    remove 0.5 from {x}
                    set {bottom_half_of_circle} to true
                    set {top_half_of_circle} to false
            else if {bottom_half_of_circle} is true:
                remove 0.5 from {x}
                if {x} is less than ({radius} * -1):
                    add 0.5 to {x}
                    set {top_half_of_circle} to true
                    set {bottom_half_of_circle} to false

            wait 1 tick
Why the global vars? just use the circle function from my sexy shapes script
 
  • Like
Reactions: NewbyZ
Done, thanks :emoji_slight_smile:

(Final result, maybe useful for someone)

code_language.skript:
command /circle:
    permission: o.o
    trigger:
        spawn an armor stand at player's location
        set {_a} to spawned armor stand
        set gravity of {_a} to false
        set {circle} to true
        set {_l} to player's location
        set {_radius} to 1
        set {_angle} to 20
        set {_rotation} to 180
        set {_current} to 0
        while {circle} is true:
            add {_angle} to {_current}
            set {_l} to {_location}
            add ((cos ({_rotation} / 180) * 3.14159265358979323846) * ((cos (({_current} / 180) * 3.14159265358979323846)) * {_radius})) to x-loc of {_l}
            add (sin ({_rotation} / 180) * 3.14159265358979323846) * ((cos (({_current} / 180) * 3.14159265358979323846)) * {_radius}) to y-loc of {_l}
            add (sin (({_current} / 180) * 3.14159265358979323846)) * {_radius} to z-loc of {_l}
            teleport {_a} to {_l}
            wait 1 tick
 
Last edited by a moderator:
Status
Not open for further replies.