#Store "Direction" into a variable

1 messages · Page 1 of 1 (latest)

dense wigeon
#

Problem: I am unable to store the direction of something in a variable. As an example, the player's current head rotation.

I am trying to make a simple script that turns an egg that is thrown into an ender dragon fireball which will launch like a regular fireball. However, I cannot seem to be able to store the direction of the player into a variable so that I can tell the program to push the fireball in said direction.

Code example:

on shoot:
    if projectile is an egg:
        cancel event
        set {_player} to shooter of projectile
        set {_loc} to location of projectile
        spawn dragon fireball at {_loc}
        set {_dir} to direction of player ← ← ←
        push last spawned entity forward in direction {_dir} at speed 1 ← ← ←

It's been quite a while since I've messed around with skript - if there was an update and this no longer works, lmk. thx!

toxic cypress
#

What's the error?

shadow gazelle
#

Why not just make the player shoot the fireball

dense wigeon
toxic cypress
#

You can also use:

set {_vector} to vector from yaw (player's yaw) and pitch (player's pitch)
push last spawned entity {_vector}
dense wigeon
toxic cypress
#

If you only want it to shoot horizontally, you simply set the pitch to 0

dense wigeon
#

thx. i'll update you on if it works

shadow gazelle
#

Pretty sure you can shoot any entity

dense wigeon
#

oh?

toxic cypress
#

Yeah you can

dense wigeon
#

dear god

shadow gazelle
#

So just shoot dragon fireball

dense wigeon
toxic cypress
#

it tells you why

dense wigeon
#

new code:

on shoot:
    if projectile is an egg:
        cancel event
        shoot dragon fireball
toxic cypress
#

shoot ... from ...

dense wigeon
#

oh wait

toxic cypress
#

if you omit the from ... part, it'll use the player event value. In this case there is no player event value

dense wigeon
#

SOLVED ✅

SOLVED ✅

SOLVED ✅

Notes:

  • It seems like "direction" has changed significantly in the last half a year or so
  • To store a direction, one of the solutions is to set {_vector} to vector from yaw [object's yaw] and pitch [object's pitch]
  • Edit: the new syntax appears to be facing of player. So the new syntax would be (for example ) set {_dir} to facing of player
  • In terms of shooting something, simply use the "shoot" command. Though, in most cases, the projectile's shooter needs to be stored within a variable and referenced within the command
light crag
#

but vectors are superior imo

scenic hazel
#

set {_direction} to in direction of player 😵

light crag
#

we don't talk about in

#

exprdirection is a scourge on society

scenic hazel
#

set {_dir} to in direction of player from

#

this syntax is a mess and always was

light crag
#

see the eldritch horrors it allows

#

it's a war crime tbh

spice radish