#Animation for custom rotation from JS script

1 messages · Page 1 of 1 (latest)

charred cairn
#

I have a sphere entity which i want to be able to rotate on the x and y axis from a script. I figured out the script API part - i'm using the entity.setRotation() function which is described as modifying The x and y rotation of the entity. For most mobs, the x rotation controls the head tilt and the y rotation controls the body rotation.

The problem is i can't figure out which queries to use in the animation file to get the rotation from that function.

This is currently my animation file:

{
    "format_version": "1.8.0",
    "animations": {
      "animation.sphere.roll": {
        "loop": true,
        "bones": {
          "root": { "rotation": [ "query.head_x_rotation(0)", "query.head_y_rotation(0)", 0 ] }
        }
      }
    }
  }

Right now, I call the setRotation() function when the entity is spawned, and the sphere seems to correctly rotate on the y axis (interpolated), but on the x axis it interpolates to the angle i gave it (45°) and then immediately goes back to 0, making a sort of bobbing motion, once.

Any idea how to fix this?

#

in the video, i am showcasing what happens when i use q.body_x_rotation and q.body_y_rotation. the x axis bobbing motion is the same as it was when i used q.head_x_rotation, but without any y axis movement

heavy umbra
charred cairn
#

not to face the camera

#

but i don't know how to rotate it like it is in the script

heavy umbra
#

But you want it to rotate ah 45°

charred cairn
#

at any angle i tell it, 45° is an example

heavy umbra
#
 {
"query.rotation_to_camera(0)", "-query.body_y_rotation + query.rotation_to_camera(1) + 45",
            0.0
charred cairn
#

what's the rotation_to_camera for?

heavy umbra
#

So see that and tell me what comes out

charred cairn
#

ok

heavy umbra
charred cairn
#

that's not what i want

charred cairn
#

not what i am trying to do

#

i have a JavaScript script

heavy umbra
#

Ok you can make the body turn 45°

charred cairn
#

i want to send the rotation value from the script

#

so if the script says 26° it's 26°, if it says 100, it's 100

#

and i am using setRotation() for that

#

but i don't know what queries setRotation () changes

heavy umbra
#

Ok you should see the setRotation() function

heavy umbra
charred cairn
#

"The x and y rotation of the entity. For most mobs, the x rotation controls the head tilt and the y rotation controls the body rotation."

heavy umbra
#

Pocketmine is like a behavior package

charred cairn
#

not pocketmine, i am using script api

#

but this question is beyond script api

heavy umbra
#

Okey

#

example look at this

charred cairn
#

so the question is - what query do i need for the "head tilt" and what query for the "body rotation"

heavy umbra
#

Example setRotation(new Vector2($x, $y);

#

Okey

#

But you need to get the x and y values

#

That if you generate the entity with its same variable, it gives them to you

charred cairn
heavy umbra