#Math animations and math.random
1 messages · Page 1 of 1 (latest)
Send the animation that you put together to do this.
done
i can send you more files if you need it
i use the /playanimation command
Oh that barely works for anything. What is the context of this?
ill be back in some time got to go
and the context is i wanna do some type of evocation fang that randomizes its size
Ah, so these entities just spawn, play the animation, and quickly despawn? You'll want to have the animations specified in the client side entity definition and played from there.
ty but my problem now is with getting the animation to work
Gotta get the animation to play first.
If you set "scale" to, say, 5, does it reflect?
like "scale": 5
Yeah.
doesnt work
Okay, so that shows that the animation is not playing. Have the animation defined in the client side entity definition instead.
so on RP/entities/test
And then also:
"scripts": {
"animate": [
"animation_test"
]
}
it worked
the only problem is when i changed "scale" to "scale": "v.scale = v.scale ?? 0; v.anim_time = v.anim_time ?? q.anim_time; q.anim_time >= 3 && v.anim_time < 3 ? { v.scale = math.random_integer(1, 10); }; v.anim_time = q.anim_time; return v.scale;"
it didnt do nothing
So the "scale": 5 worked and the entity was 5 times the usual size?
and it seems to run this one but instead of changing size the entity becomes invencible or size 0 i think
Try replacing v.scale = v.scale ?? 0; with v.scale = v.scale ?? 2;
its visible but even after 3 seconds nothing happens
That shows that it's an issue with the animation timer logic.
Replace return v.scale; with return q.anim_time; and see what happens.
the entities dissapeared
This suggests that the animation timer is not advancing.
Try replacing the whole thing with:
"scale": "v.scale = v.scale ?? 0; v.anim_time = v.anim_time ?? 0; v.anim_time + q.delta_time >= 3 && v.anim_time < 3 ? { v.scale = math.random_integer(1, 10); }; v.anim_time = v.anim_time + q.delta_time; return v.scale;"
YO TYSM
it works perfectly
but how i make them smooth
because after 3 seconds it just pops
Do you want it to be a smooth transition into the random size over the course of those 3 seconds?
"scale": "v.size = v.size ?? math.random_integer(1, 10); v.anim_time = v.anim_time ?? 0; v.scale = v.size*math.sin(math.min(v.anim_time, 3)*30); v.anim_time = v.anim_time + q.delta_time; return v.scale;"
if its possible yea
just tried this one
its amazing
btw what are the ?? for
That is a null coalesce. It uses the first variable, unless it's undefined, then it uses the second variable.
It's good for initializing things.
The semicolons just separate the different instructions.