#Molang General
1 messages · Page 4 of 1
yes
query.hurt_time
I tried it, didnt work, apparently it works only with boats and etc
I had to do some workarounds, but I got working what I was trying to do
Hey guys I have a question, why the ```
geometry.humanoid.customSlim
Changes when the player selects a custom skin? On my project the player uses the slim model, but when I select a custom skin for some reason the item position changes, it's like custom skin uses another model
If that's the case, is there a way to change the other model?
where should i put the semicolon for this?
Needs to be == not =
alr
At the end of the line like dis for example "q.is_on_ground ? 1 : 0;"
The query that says has target needs the = to be ==
Is it possible to change the inflation animation of the Creeper or TNT?
Hello, I'm trying to create animations not affect by vanilla ones, I'm using -this on them but they see like they are just changing the values of the whole animation? is there some page/documentation/info about this and how to use it to "cancel" vanilla animations? Like bob or running ones. Thanks
"t.prop_y = query.property('c:y');",
"t.changed_y = math.abs(t.prop_y - v.target_y) > 0.01;",
"t.changed_y ? { v.prev_y = v.current_y; v.target_y = t.prop_y; v.progress_y = 0; };",
"v.progress_y = math.min(v.progress_y + q.delta_time * 2.5, 1);",
"t.diff_y = v.target_y - v.prev_y;",
"t.diff_y = t.diff_y + (t.diff_y > 180 ? -360 : 0);",
"t.diff_y = t.diff_y + (t.diff_y < -180 ? 360 : 0);",
"v.current_y = v.prev_y + t.diff_y * v.progress_y;",
I’m trying to create interpolation using this feature, but when it goes from 0 to 360 or from 360 to 0, it makes a full rotation, which causes a problem. How can I fix this?
yeah, 25 bits, it's pretty bad for certain use cases
yeah..
ig my best thing rn is just a ton of variables
Why does molang exist
Hey Molang is neat
That's what THEY want you to think
Or maybe YOU want YOU to think the opposite
Is there any way to pass a value for a toggle into molang in a resource pack?
something like a tag or scoreboard or something. Ideally I can set it with scripts
also, something that sets a variable on the player would also work
nvm, I solved it. run /playanimation "some_animation" none 0 "v.variable = 1;"
so im getting an "unrecognized token" error with the molang string in this file (great job Mojang, not explaining CRAP about whats wrong) and i dont know why, anyone else know?
the biome tags aren't surrounded by '
...
o h
lemme see if that fixes it
well that issue is gone
but one still remains
the variable isnt getting registered
probably because its in the feature rules file?
what is the best molang for animation controllers for walking cause my animation controller on walking keeps jittering im using a smooth keyframes in my animations combined with linear keyframes i dont why it keeps jittering
query.ground_speed >= 1.0 for when walking
query.ground_speed < 0.05 for when idle
I feel like you can just use is_moving
Is there a bug with the camera rotation query that makes it not work on attachables
I've attempted using it and it rotated kind of weirdly
Nvm, figured out my problem
But that triggers animation if the player or another entity pushes it
Perhaps do both conditions?
It won't work correctly in attachables, since other rotations are being applied to accommodate first and third person.
I use query.modified_move_speed>0.5 so that the walking animation only activates when walking and not when being pushed.
I already said that I'd gotten it to work for me
Its fine
I didn't see it xd
Lol
@atomic rover
query.movement_direction
query.movement_direction(0)
query.movement_direction(1)
query.movement_direction(2)
yeah i figured it out, im just dealing with the exact movement direction stuff, like its now detecting both north and east instead of just north or just east,
umm, i couldnt really understand how to make it trigger my animations correctly
like in my controller, moving towards north should trigger the north animation, which will makes my vines goes to the south
in short, i am trying to make some fake physics for my vines, where they will rotate based on how fast u are moving and what direction
well, its not cardinal direction
its for checking moving forward, backward, left or right.
then how can i use the cardinal direction one?
Can't you just check for Body Rotation then?
does it work on attachables?
cuz i want to play the animations that will make some fake physics depending on the direction u are moving into
So what does this have to do with attachables?
bec the item i am animating is an attachable,
Are you trying to query the entity or the attachable. If the attachable why did you ask how to get the entity's rotation.
just didnt know that attachables can detect the holder entity rotation/stuff,
-# im kinda new to molang/animations btw
That's irrelevant really. Just get the entity's rotation, didn't need to bring up attachables.
i believe i just have to detect the cardinal direction, so when u try moving forwards, the forward animation will play,
what should i use for that?
maybe he just wanted to know if it was possible to pass the data over to attachables.
Ok so you don't really know what you want.
Because this is exactly what you need.
Not cardinal stuff.
cuz im kinda new to these stuff?
ig ill deal with it tomorrow,
its more like holding a lantern, moving forwards the lantern to rotate backwards, im trying to recreate that type of physics
yeah we understand, cardinal direction is just not the thing for this.
i see
"initialize":["v.movement_x = 0;","v.movement_z = 0;"],
"pre_animation":["v.movement_x = math.atan(q.movement_direction(0));","v.movement_z = math.atan(q.movement_direction(2));"]```this is how u use it, right?
lemme show u what i am using/the results
well if you want forward and backwards, it would just be 0, foward being positive and negative being backwards
I believe
or are you going for side aswell
here
ofc i am,
north south east west, they all got the rotation animation
its more like this:
north-east = the vines are going south-west, both animations will play at the same time making the item moving towards south-west
and i believe in the rotation stuff, i can add some math or something to make the rotation goes further depending on the player movement, so the physics looks right
i think i only need two controllers, one for north-south and one for west-east for smoother transitions or whatever
yeah,
ill use two controllers, since u cant run two states in one controller at the same time (bec i dont want to add more animations for more states in one controller)
i think you are going about it wrong.
ig u can help me with the v.movement_x thing,
only 1 controller is needed
mhm,
with only 4 states for each direction?
or i have to add an extra 4 states for the diagonal directions?
yeah, 8 states.
wait, i see it now, 8 states, the diagonal ones can be achieved by adding more animations to the "animations" things
just make 4 diagonal animations
ill make the animations later on, for now ill just rotate the vines depending on the direction with no diagonals
can u help me with that?
like just the query/variable thing
im currently working on something rn, im sure someone else can assist
alright, gl with ur work!
you too
ay, the only issue i am facing with the movement_direction is that it detects a whole direction (like from north to east, the whole side is considered north in my system)
so thats why the wrong animation is keep getting played, its bec the north animation is being played with the other directions like east or west
can i at least debug the variable? so i can make some transition conditions better or somethin
like output the value? the only possible way to view the query's values I can think of in real time is make a property on the player in it's file and use the ticking component that sets the property value to the query's value.
seems like alot of work
and then in scripts, get the property's value and output in console.warn() or something to see the value
not really
d u know how much is the output can reach?
like from 0 to 120 or something?
i just have no idea where it stop or reaches the maximum
well the query's value wont surpass 1 or below -1 for each axis I believe.
so that's not a problem at all
the limit is also pretty high iirc
ill just deal with it tomorrow,
by debugging the axis
or maybe downloading some animation packs that might have some fake physics animations and see how they made it,
if they are fine with it, sure
using what query?
q.movement_direction(0) doesn't seem to work in the BP, either the variable from the client entity,
hmm, ill try using cardinal queries, they might work better than the movement direction
cuz i want to play the north animation whenever u move forward, doing this should work better since the north animations wont run when u move towards the north backwards,
maybe using both movement_direction and cardinal_facing to play the correct animations
so if u are facing south and moving towards north, it will play the south animations
apparently the fake physics animations are harder than i expected lol
well,
look at the hanging vines near the handle,
the way they move is great if u move while looking at the right direction
heres the code:
"controller.animation.xfallenwarriors.ancient.sword.vines.direction0":{
"initial_state":"null",
"states":{
"null":{
"blend_via_shortest_path":true,
"blend_transition":0.15,
"transitions":[{"is_north":"(v.movement_x > 35)"},{"is_south":"(v.movement_x < -35)"},{"is_east":"(v.movement_z > 35)"},{"is_west":"(v.movement_z < -35)"}]
},
"is_north":{
"blend_via_shortest_path":true,
"blend_transition":0.25,
"animations":["vines.movement.north"],
"transitions":[{"null":"(v.movement_x <= 0)"}]
},
"is_south":{
"blend_via_shortest_path":true,
"blend_transition":0.25,
"animations":["vines.movement.south"],
"transitions":[{"null":"(v.movement_x >= 0)"}]
},
"is_east":{
"blend_via_shortest_path":true,
"blend_transition":0.25,
"animations":["vines.movement.east"],
"transitions":[{"null":"(v.movement_z <= 0)"}]
},
"is_west":{
"blend_via_shortest_path":true,
"blend_transition":0.25,
"animations":["vines.movement.west"],
"transitions":[{"null":"(v.movement_z >= 0)"}]
}
}
}```
currently, i just want to get the animation to work properly, ill add the diagonal ones later on
q.cardinal_facing_2d == 2 doesnt work?
i tried adding it as variable and having it inside "per_animation" similar to movement_direction stuff, it doesnt really work
i even tried adding c.owning_entity -> and still it doesnt work, my animations isnt playing while facing the 'north' cardinal
@proud token these ones,
do i need to detect the body y rotation or something?
i see,
thats why i was trying to use cardinal direction, so i can detect where u are looking to play the correct animation
I still think cardinal direction is not what you need for this.
what about detecting when i rotate my head (left/right)? bec the q.camera_rotation didnt seem to work on the attachable, do i have to use owning entity or something?
again, not knowledgeable man, I dont work with molang that much
i see,
I'm going to be working with the movement direction query myself soon, so maybe when I do I can help out after
understood, ig gl with ur other works,
for me, ill just keep on trying other queries or even using some BP typa variables
to like control the animation controller using scripts instead of queries
i believe i have to use player.json for that, right?
hm, could be possible but it would be more performant fully client side
by scripts you mean js right
or scripts inside the entity.json file
so no
since you are using scripts
you can use playAnimation
playAnimation doesnt work on attachables afaik
but like I said, fully client side would be way better
not in FP i believe
ah right, but there is a way to pass variables over to attachables in scripts.
i see, ill deal with it later on,
Minato has the code for that.
like all i really want to do with the queries is to detect when u move forward, backwards or to the sides,
which that query should be for
i mean, as u can see in the vid, the movement_direction works based on the workd directions not the player movements
i mean, it will play the south animations whenever u move towards south, no matter if u were moving forwards or backwards or even sideways
i havent worked with this query before so ill report back when I get around to using it
basicly this
https://discord.com/channels/523663022053392405/1463304436330922014
but i have my version of it
do i have to add something to the playAnimation to make it work?
read bellow the post
export function setTempVars(player, data) {
const random_1 = (Math.random() * 1e3) << 0;
const dataEntries = Object.entries(data)
.map(([key, value]) => `v.movement_${key}=${JSON.stringify(value)};`)
.join("");
const stopExpression =
dataEntries +
`return 0;`;
player.playAnimation("animation.xfallenwarriors.direction", {
controller: "animation_controller_set_"+random_1,
stopExpression,
});
}
system.runInterval(() => {
for (const player of world.getAllPlayers()) {
const input = player?.inputInfo;
const {x, y} = input.getMovementVector();
if (y > 0) setTempVars(player, {x:2})
}
})```is there anything wrong?
"animation.xfallenwarriors.direction":{"animation_length":0.05},
attachable
"parent_setup":"temp.attack_dur = v.attack_time ?? 0; t.movement_x = v.movement_x ?? 0.0; t.movement_y = v.movement_y ?? 0;",
"initialize":["v.rmovement_x = 0.0;","v.rmovement_y = 0;"],
"pre_animation":["v.rmovement_x = v.movement_x ?? 0.0; v.rmovement_y = v.movement_y ?? 0;"]```
oh, t.movement not v
fixed,
well, ill just stick with the scripts side for now
it works pretty damn well
as u can see,
now i can start working on polishing the animations
btw, is this a healthy way of running the animation stuff?
const {x, y} = player?.inputInfo.getMovementVector();
if (x === 0) setTempVars(player, {x:0});
if (x < 0) setTempVars(player, {x:1});
if (x > 0) setTempVars(player, {x:2});
if (y === 0) setTempVars(player, {y:0});
if (y > 0) setTempVars(player, {y:1});
if (y < 0) setTempVars(player, {y:2});```
I think Actions & Stuff also had physics like that, but it was only a resource pack—how did they make that?
Hi
"scripts": {
"pre_animation": ["variable.smoothed_speed = 0;"],
"initialize": [
"variable.smoothed_speed = math.lerp(v.smoothed_speed, q.property('bs_mb:speed'), 0.1);"
],
"animate": ["idle"]
}
I created a variable in pre_animation but not sure why the game said unknown variable?
"scripts": {
"initialize": [
"variable.smoothed_speed = 0;"
],
"pre_animation": [
"variable.smoothed_speed = math.lerp(v.smoothed_speed, q.property('bs_mb:speed'), 0.1);"
],
"animate": ["idle"]
}
I think this is correct
is there any way to prevent this from showing up a log when the holder entity doesnt have that property?
"pre_animation":["t.movement_x = q.property('xcore:direction.x'); t.movement_y = q.property('xcore:direction.y'); t.rotation_x = q.property('xcore:head.rotation.x'); t.rotation_y = q.property('xcore:head.rotation.y');"]
adding ?? 0 doesnt fix it + it has a log (unsupported)
try q.has_property('xcore:direction.x') ? q.property('xcore:direction.x')
For a system like oxygen mechanics, is it better to use tags and scoreboards, or should I move to scripting for better performance and scalability?
does anyone know what could cause this very cryptic error? it's happening inside a feature
there's quite a few things going on in the expression which gets assigned, but the only thing that stands out is math.ease_out_circ(), maybe that's causing it?
Usually means something like a division by 0 or sqrt or log of a negative number, watch out for things like that
Regarding the easing function, if it is truly the source of the error, maybe it doesn't handle values of 0, 1, something close to either of the two or -0
is there any way to change the temp value the second u switch items?
currently the system i am using to add a custom pull/draw animation, requires holding an attachable to work
for example, if u hold nothing or hodl another item (without attachables) and then switching back to my item, it wont play the pull/draw animations,
t.pull = q.is_item_name_any('slot.weapon.mainhand', 0, 'xfallenwarriors:ancient.sword.v1') inside "pre_animation" inside my attachable
is it fixable without having to use scipts/commands?
I was told that apparently if you play the animation that plays at the start with an animation controller, it removes this problem
But in my experience of doing this that in the past, no dice
So you're welcome to try for yourself, maybe it will work for you
i am using the t.pull inside the animation controller
"controller.animation.xfallenwarriors.ancient.sword.pull":{
"initial_state":"not_pulling",
"states":{
"not_pulling":{
"transitions":[{"is_pulling":"(t.pull == 1 && c.is_first_person)"}]
},
"is_pulling":{
"blend_via_shortest_path":true,
"blend_transition":0.25,
"animations":["pull"],
"transitions":[{"not_pulling":"(t.pull == 0)"}]
}
}
}```
Is t.pull always true currently?
when u switch from the attachable to anything else (that is not an attachable, like a normal item or ur barehands) it wont change the value back to 0
as u can see, the vanilla spear uses an attachable, switching to it does change the value back to 0, thats not the case with other non-attachable items or with ur hands
Ok that was a terribly stupid way to ask my question 🤦♂️
so, is there like a query that will detect when u stop holding the attachable? so the value can go back to 0
i could use scripts or BP player animation controller/player properties
but it has a delay or could be heavy unlike the client side ones
like high ping can cause some visual bugs in the animations
I get it, just trying to figure out any more convenient solutions
Plus, that's a waste of a property
indeed
try !t.pull, idk worth a try
nope, still doesnt work
how do i query if the player is in first person in an animation played using playanimation?
query.is_first_person works for me
If it doesn't for you, then there's also variable.is_first_person
the variable worked ty
No problem 👍
This is not 100% consistent when quickly switching but it does work.
{
"format_version": "1.19.0",
"animation_controllers": {
"controller.animation.AAAAAAAAA": {
"initial_state": "default",
"states": {
"default": {
"animations": [
"draw"
],
"transitions": [
{
"idle": "q.all_animations_finished && (t.current_time = query.time_stamp; t.result = t.current_time - v.last_time <= 1? 0 : 1;v.last_time = t.current_time;return t.result);"
}
],
"blend_transition": 0.2
},
"idle": {
"animations": [
"idle"
],
"transitions": [
{
"default": "t.current_time = query.time_stamp; t.result = t.current_time - v.last_time <= 1? 0 : 1;v.last_time = t.current_time;return t.result;"
}
],
"blend_transition": 0.2
}
}
}
}
}
ig ill give it a shot after this damn windows update finishes, my laptop is stuck at the first restart
Took me 2 days to figure it out lol
damn, i was about to change the whole system into JS
like having to interact to pull the sword instead of switching to it instantly
100% in the attachable, also should initialize the v.last_time = query.time_stamp; in the "initialize" : [] part of the attachable
making fake physics without using scripts is possible in attachables, right?
currently i am using some JS math to detect the player movements correctly, i am changing the player property so the attachable can read the change and understand where the player is moving to play the fake physics animations
i could use that q.movement_direction
but it just doesn't really work that well
Yeah. You can fake it with molang. There's a couple of properties, queries and variables you can use to do it. You'll probably need to do some advanced stuff though
like it did work, but only when u walk into some directions while looking at a specific direction
it looks good rn
even though it has a 1 tick delay, it is working better than the system i made with molang
movement direction takes a parameter to specify what axis to return from what it looks like
Elytra animation uses query.movement_direction(1); which is probably the Y axis
for my fake physics, i need to detect whenever u move in a direction, it doesn't matter where u are looking, (lets say u was looking at north-northwest or somewhere like that and u walked forward, it should detect that movement as forward instead of north-northwest)
i did manage to achieve that using scripts, idk if i can with molang
Probably need to use a combination of cardinal facing and movement speed
cardinal queries doesn't work
at all
i tried everything, nothing works, they've bugged
Cardinal in MC is stupid. It's completely reversed
You can also just get the entity rotation
i could,
but idrk if my brain can handle this much math
also,
is there a specific molang for interacting/attacking?
currently, the v.attack_time is returning every single hand rotation
you'll have to combine all the attacking queries then
currently, i am using some scripts to change the player property in order to trigger the attack animation separately from the interact animations
There is q.modified_swing_duration but that might be it.
I'll figure it out later. I've only really started messing with molang a week ago
dang, u got some decent knowledge
-# better than what i got imo
maybe bec I'm not really dealing with that many molang, like the last time i touched it is when i wanted to make my goatfur armor dyeable
tho, my next addon will use alot, aLot of molang for some advanced client player nonsense
is there a query for the current lifetime of an active animation controller state?
nice, thanks
is it possible to early return in a molang script?
Yes, you can use return to early return value for the whole molang statement. See documentation for complex molang expressions
I'll rephrase, is it possible to have a conditional early return?
So, not for the whole molang expression but from local scope?
for example i tried
(v.worldx > 64) ? {return false;}
return v.worldx > -64;
it's just an example, I know that in this case I could combine the experssions but I want to somehow have the option to run a lot of early returns like that to save on needless computation
You can either just avoid early returns and structure the code using conditional logic, or you can use loop(1, {}) with break, to achieve similar functionality. These are the only 2 options, as molang doesn't support returning from local contexts
I'm using it in the iteration fields of a scatter feature, is that considered local?
By local I mean anything more granular than the entire molang string
so for the loop thing it'll be something like
loop(1, {
(v.worldx > 64) ? {break;}
return v.worldx > -64;
})
return false;
So in short, return always returns the value for the whole molang string where it was used
But you can't use return to simulate functions within molang, so something like this won't work
v.sqrt = {v.foo < 0 ? {return 0;}; return math.sqrt(v.foo); }; // This will return either 0 or sqrt(v.foo) for the whole molang string
return 2*v.sqrt; // This code never runs
You only need to use loop trick if you need to do early returns like the one I outlined above. If it were to be rewritten to use a loop, it'd look like this
loop(1, { v.foo < 0 ? {v.sqrt = 0; break;}; v.sqrt = math.sqrt(v.foo); });
return 2*v.sqrt;
But, for early returning a value for the whole scatter iteration molang field, return will work just fine
I'm having a hard time understanding it
how would you write this logic?
v.a = 1;
v.b = 1;
v.c = 1;
if (v.a != 1) return false;
if (v.b != 1) return false;
if (v.c != 1) return false;
return true;
If this is the entire molang string, then way you wrote it is correct
cant you just dojs (v.worldx > 64) ? {return false;} : (v.worldx > -64) ? return true;
"query.variant==2 ? Geometry.captain : Geometry.default" this would set the geometry to the captian geometery if variant evaluated to 2 right? Also this is in a render controller.
yes, it should
Ty
yao, what should i use to play an animation specifically for the attack whole playing a different animation with the normal hand rotation?
currently,
"controller.animation.e.attack":{
"initial_state":"not_attacking",
"states":{
"not_attacking":{
"blend_via_shortest_path":true,
"blend_transition":0.15,
"transitions":[{"is_attacking":"(c.owning_entity -> v.attack_time > 0 && c.is_first_person)"}]
},
"is_attacking":{
"blend_via_shortest_path":true,
"blend_transition":0.25,
"animations":["attack"],
"transitions":[{"not_attacking":"(q.all_animations_finished && c.owning_entity -> v.attack_time == 0)"}]
}
}
},```is playing the attack animation each time i swing my arm, which looks off when interacting or doing anything else that can rotate ur arm
I dont think you can detect that
you can using scripting only
so detect it with scripting and use temp leaking
using some play animation nonsense?
Is there any way to detect the texture of entity and turn them into scores using molang like texture1 = 1 scores texture2= 2 scores and so on
thanks! it works like a charm
epic
how do you change the texture of your entity?
Small question: you can use double exclamation points in molang to check for truthy values, right?