your current location:首页 > news>YSM tutorial -variable [ysm] is, the Yes Steve Model Minecraft Game

YSM tutorial -variable [ysm] is, the Yes Steve Model Minecraft Game

2024-12-10 17:45:04|Myriagame |source:minecraft skins

This tutorial is set by the author to use the CC By-NC-SA protocol.

What is a variable?

Variables are some readable parameters in MC. They record the behavior of players, such as the perspective of the head, the speed of walking, the health of the player, and so on.By reading these variables, some custom behaviors can be achieved on the model.

For example:

When the head is raised, the hair behind it also rotates backwards to offset the rotation of the rise, avoiding the entire hair through the hair through the chest.

For example:

Detect the vertical speed of the player, let the hair float when the whereabouts are falling, and make the model more real.

What are the types of variables?

Readable variables: query.xxx can be readable or not, only real -time behavior in the entity or game.The abbreviation is Q.XXX.

Recent variables: Variable.xxx readable can be written and stored in the entity. It needs to be written by assignment.The abbreviation is v.xxx.

Temporary variables: TEMP.XXX readable, temporary storage variables will be destroyed after an animation cycle.Not abbreviated.

Supreme variable: Variable.Roaming.xxx is equivalent to physical variables, but it will not be reset when exiting games or switching dimensions. It can be abbreviated as v.Roaming.xxx.

How to modify physical variables?

The physical variables need to change its value by assignment, otherwise its initial value is NULL.

The assignment symbol is =

(Note) = is assignment, == is equal to

Example: variable.jump = query.is_jumping.

query.is_jumping can read whether the player is in a jump state, and it is real -time. Suppose I need to make a jump (MC's original mechanism, the attack will cause crit during the jumping where you jump), then I can use query.is_jumpingCome to read whether the player is in a jump, but Query.is_jumping has a disadvantage. It changes in real time. When the player landed, the value of query.is_jumping will soon become 0. If you want to detect the jump only at the beginning of the animation, then the jump will be detected. After thatIf the landing will not change, it is necessary to use a physical variable.

At the beginning of the animation, variable.jump = query.is_jumping, when the player is jumping at the beginning of the animation playback, the value of variable.jump is 1, and when you do not make any modifications of Variable.jump, the value of Variable.jump will always alwaysKeep it as 1 until the next time it is assigned.

How to use physical variables in the YSM model design?

In addition to the jump detection just mentioned, there is also a transformation.The wine fox of the default model of YSM is an example.

In the Parallel animation of Jiuhu Fox, the scaling of the form and the fox form was given 1-v.Roaming.a and v.Roaming.a

At the same time, in the transformation animation, the first frame is v.Roaming.a = 1-v.Roaming.b; the second frame is v.Roaming.b = v.Roaming.a

Let's analyze how the transformation above is achieved.

In the transformation animation, the first frame is v.Roaming.a = 1-v.Roaming.b, v.Roaming.a and v.Roaming.b's initial value is null. In YSM, the NULL value is equivalent to 0Essence

So the first frame is v.Roaming.a = 1-0; at this time the value of v.Roaming.a is 1.

The second frame is v.Roaming.b = v.Roaming.a. At this time, the value of v.Roaming.a is 1.

Then the second frame is v.Roaming.b = 1, and the value of v.Roaming.b is 1 at this time.

Parallel will continue to be played as a parallel animation. At this time, the human form is zoomed in 1-v.Roaming.a, which is 1-1 = 0, then the human form is hidden, and the fox's zoom is v.Roaming.a, which is 1, which is 1At this time, the fox form is displayed.

Then the second round of transformation is still the above process, but at this time the values ​​of V.Roaming.a and v.Roaming.b are 1.

Then the first frame is v.Roaming.a = 1-1; at this time the value of v.Roaming.a is 0.

The second frame is v.Roaming.b = v.Roaming.a. At this time, the value of v.Roaming.a is 0.

Then the second frame is v.Roaming.b = 0, at this time the value of v.Roaming.b is 0.

At this time, the human shape was zoomed in 1-v.Roaming.a, that is, 1-0 = 1, then the human form is displayed, and the zoom of the fox is v.Roaming.a, that is, 0, at this time the fox shape is hidden.

There are many more examples, such as multiple attacks, which is also a counter to perform animation switch by detecting solid variables.

Here I will no longer describe it in detail, put a piece of the counter I often use:

The first frame v.a = v.b+(v.b> = 2? -V.b: 1)

Frame v.b = v.a

This Molang will make V.A initially 1, and every time the animation will be +1, it will return to zero until the total of 3 o'clock, that is, the play order is 1 2 0 1 2 0 and so on. You can change 2 to the number of paragraphs you need.For example, you have made eight attacks, that is V.A = v.b+(v.b> = 7? -V.b: 1), the play order is 1 2 3 4 5 6 7 0 ...

You can even use the math.random function to play randomly, such as v.a = math.random_integer (0,7)

Based on the readable and storeable characteristics of the physical variable, the sweet rice dumplings also wrote a series of physical simulation related animations. These are the next period.

How to debug and optimize physical variables?

If there is a problem with the physical variable, you can find and solve it with instructions.

For example, I want to know why this solid variable is wrong when it is executed. How do I see the value changes during the execution process?

This requires the/ysmclient instruction

usage:

/ysmclient molang watch add post name variable name

example:

/ysmclient molang watch add post v.a v.a

/ysmclient molang watch add post tiaoyue q.is_jumping

After the input is entered, turn on the debugging interface of the YSM, that is, the Alt+B is pressing twice, and you can see the real -time value of the variables you added, so that you can make debug.

Want to learn more?

There are many tutorials and resources on the Internet to learn more about physical variables.

For example, the development of wiki development of the base rock version:

https://bedRock.dev/zh/docs/stable/molang

If you feel that you have mastered the foundation, you can challenge some more advanced gameplay.

You can also join some player communities to communicate with other players/model authors.