#Math animations and math.random

1 messages · Page 1 of 1 (latest)

weak yew
#

how i can make it so in a math animation the math.random expression only gives 1 random value at a certain time and not generate random values everytime it can

hardy grove
weak yew
weak yew
#

i can send you more files if you need it

hardy grove
# weak yew

Have you confirmed that the animation is actually playing?

weak yew
hardy grove
weak yew
weak yew
hardy grove
weak yew
hardy grove
#

Gotta get the animation to play first.

#

If you set "scale" to, say, 5, does it reflect?

weak yew
hardy grove
#

Yeah.

weak yew
#

doesnt work

hardy grove
# weak yew doesnt work

Okay, so that shows that the animation is not playing. Have the animation defined in the client side entity definition instead.

hardy grove
#

Yeah that one.

#

RP/entity/test.json

weak yew
#

like this?

#

"animations":{
"animation_test":"animation.test.test"
}

hardy grove
#

And then also:

"scripts": {
  "animate": [
    "animation_test"
  ]
}
weak yew
#

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

hardy grove
weak yew
hardy grove
#

Try replacing v.scale = v.scale ?? 0; with v.scale = v.scale ?? 2;

weak yew
#

its visible but even after 3 seconds nothing happens

hardy grove
#

That shows that it's an issue with the animation timer logic.

hardy grove
hardy grove
#

This suggests that the animation timer is not advancing.

hardy grove
# weak yew the entities dissapeared

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;"
weak yew
#

it works perfectly

#

but how i make them smooth

#

because after 3 seconds it just pops

hardy grove
#
"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;"
weak yew
#

its amazing

#

btw what are the ?? for

hardy grove
#

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.

weak yew
#

oh

#

you really good at this ty

#

and the ; ???

hardy grove
#

The semicolons just separate the different instructions.