#Spinning Armor Stand that moves into the direction where player is looking.

1 messages · Page 1 of 1 (latest)

lone solstice
#

Self explanatory title, i tried making my own code for this but it doesn't seem like working, I recently started learning about vectors and uh I'm kinda rusty at it. My goal is to let the armor stand move towards the target block slowly and then when it touches a wall or ground it disappears. Here's the code I have so far:

#
on right click:
    player is holding a iron hoe
    if name of player's held item is "%{goofy.staff}%":
        cancel event
        play sound "entity.ghast.ambient" with volume 1000 to all players in radius 3 around player
        spawn 1 armor stand at location of player
        add nbt compound from "{Invisible:1b}" to nbt of last spawned armor stand
        add nbt compound from "{NoGravity:1b}" to nbt of last spawned armor stand
        set helmet of last spawned armor stand to player head
        set {astand::%last spawned armor stand%} to "goofy"

        set {_v} to vector from player to target block
        set vector length of {_v} to 0.1
        set {_loc} to location of player
        loop (distance between {_loc} and target block) / 0.1 times:
            loop all armor stands:
                if {astand::%loop-entity%} is "goofy":
                    teleport loop-entity to {_loc}
                    set {_loc} to {_loc} ~ {_v}

                    if block below loop-entity is not air:
                        delete loop-entity
                        stop```
#

please don't mind the last few lines lol i am just out of ideas

high mantle
#

why you looping all armor stands

feral jacinth
#

While armor stand is alive.

lone solstice
#

yes i know i removed that like 5 minutes after posting the code

cold plover
#

set the rotation tag to yaw and pitch of player

lone solstice
#

anyways with the moving of the armor stand towards where player is looking

#

whats the most efficient way of doing it

lone solstice
cold plover
#

yes

lone solstice
#

so

#
set {_v} to vector from player to target block
set vector length of {_v} to 0.1
set {_loc} to location of player
loop (distance between {_loc} and target block) / 0.1 times:```
feral jacinth
#

Yes

lone solstice
#

alright

#

and with the moving

#

what do i do IN the loop

feral jacinth
#

Set loc to loc ~ vector

#

Then tp it to the loc

lone solstice
# feral jacinth Then tp it to the loc
set {_v} to vector from player to target block
set vector length of {_v} to 0.1
set {_loc} to location of player
loop (distance between {_loc} and target block) / 0.1 times:
 set {_loc} to {_loc} ~ {_v}
 teleport last spawned armor stand to {_loc}``` so i did this but when i click again while one armor stand is currently moving it just stops
#

it may be because of the last spawned armor stand but

feral jacinth
#

Correct

lone solstice
#

cant think of another way of doing this

feral jacinth
#

Now what do you think you could replace last spawned armor stand with?

lone solstice
#

i dont know my first thought was to create a variable but that sounds bad

feral jacinth
#

Nope that's fine

#

Also make it a local var

lone solstice
#

{_}?

feral jacinth
#

Yes

lone solstice
#

got it

#

so i did this so the bullet (the head) isnt that fast but now its just too slow and you cant go below 1 tick afaik

feral jacinth
#

Increase the length

lone solstice
#

oh yeah that makes sense

#

wait why is it clipping through blocks now

#

okay nevermind fixed it

#

changed the value from 0.1 to 0.5

#

just like the length

#

okay now the rotation

lone solstice
#

ok finally got it fully working