Charm + Vide How To Update UI
I have just started using vide and charm, but i am still not sure how i could use the two of them to update my UIs, i would really appreciate any help!
123 Replies
Unknown User•5mo ago
Message Not Public
Sign In & Join Server To View
like how could i make it so that for example when the enemy's object health value changes, his overhead UI would update accordingly
in the past in luau when i used to use react i used to expose my useState from inside the overhead component to the enemy object so that it can call it when health changes, but people always said that was a bad way, so i am not sure how to do it with atoms now
in react you would subscribe to health changes from the component itself
react was just an example, i have switched to vide
@wAD does the vide have Bindings?
Unknown User•5mo ago
Message Not Public
Sign In & Join Server To View
with react i think you can still do amazing things and it depends on the structure
i had seen how littensy had done it, he had a module for each atom in his example, and not sure if the UI updates when the value changes or not
no
vide does not need them because they don't re-render stuff anyway
at least they have useAtom hook 🫠
hmm
is it possible to add and remove components dynamically like in react?
react & vide are conceptually different, vide does not have a vdom
it's more similar to fusion
ye
Unknown User•5mo ago
Message Not Public
Sign In & Join Server To View
like i wanted to try vide but still havent
Unknown User•5mo ago
Message Not Public
Sign In & Join Server To View
man charm is so good
i even ported it to js
Unknown User•5mo ago
Message Not Public
Sign In & Join Server To View
can you use vide sources outside ui
Unknown User•5mo ago
Message Not Public
Sign In & Join Server To View
i saw people raw dog state with fusion values outside UI
Unknown User•5mo ago
Message Not Public
Sign In & Join Server To View
ok one benefit of charm is that it offers cool sync functionality
Unknown User•5mo ago
Message Not Public
Sign In & Join Server To View
yeah
Unknown User•5mo ago
Message Not Public
Sign In & Join Server To View
ah
i also don't use vide
Unknown User•5mo ago
Message Not Public
Sign In & Join Server To View
personal preference 🤷♂️
Unknown User•5mo ago
Message Not Public
Sign In & Join Server To View
directly manipulating instances is kinda powerfulin what way
Unknown User•5mo ago
Message Not Public
Sign In & Join Server To View
you can do that with react ?
Unknown User•5mo ago
Message Not Public
Sign In & Join Server To View
i wouldn't say one useState hook is a lot of boilerplate but k
Unknown User•5mo ago
Message Not Public
Sign In & Join Server To View
i tried vide
Unknown User•5mo ago
Message Not Public
Sign In & Join Server To View
the latter, i don't care and i won't switch anyway
Unknown User•5mo ago
Message Not Public
Sign In & Join Server To View
second one Ive seen that has this flipped
ui should consume outside state
the outside state shouldnt update itself XD
but ig its whatever
Unknown User•5mo ago
Message Not Public
Sign In & Join Server To View
you should consume the state, ui should be a reflection of it
so the ui consumes the state
Unknown User•5mo ago
Message Not Public
Sign In & Join Server To View
in react would make more sense because you wouldnt be able to do that
for example for matter (not sure what ecs you use)
somebody made hooks for react
Unknown User•5mo ago
Message Not Public
Sign In & Join Server To View
useWorld useComponent, useQuery
Unknown User•5mo ago
Message Not Public
Sign In & Join Server To View
no, not matter hooks sorry
like I mean somebody made tooling hooks for consuming state in matter
its all about state purity, no side effects, and all of that
Unknown User•5mo ago
Message Not Public
Sign In & Join Server To View
it is backwards, you are "handfeeding" the UI state from the outside
Unknown User•5mo ago
Message Not Public
Sign In & Join Server To View
right, but you could query the state from the UI
Unknown User•5mo ago
Message Not Public
Sign In & Join Server To View
no it doesnt, thats the whole point Im talking about
if you edit some state from ecs for the ui
then the ui becomes the central state, because the ecs is responsible of that
(ecs shouldnt be responsible of the UI)
similar to the charm
useAtom
it consumes that atom state, but you shouldnt create sources somewhere and update them with the atom
you do useAtom
Unknown User•5mo ago
Message Not Public
Sign In & Join Server To View
I thini for ecs, you might use jabby I think its called right
Unknown User•5mo ago
Message Not Public
Sign In & Join Server To View
right
it would consume the state from your world
you dont update it in your ecs
ecs would be responsible for exposing the state
not providing it, and updating it
Unknown User•5mo ago
Message Not Public
Sign In & Join Server To View
ya, like charm
useAtom
Unknown User•5mo ago
Message Not Public
Sign In & Join Server To View
its an example
charm has useAtom
Unknown User•5mo ago
Message Not Public
Sign In & Join Server To View
you have your health
this in any component where you use health
Unknown User•5mo ago
Message Not Public
Sign In & Join Server To View
just an exposed state, it could be a single atom, or just a function accessing the state
Unknown User•5mo ago
Message Not Public
Sign In & Join Server To View
Im not creating a global states script
with health inside
and listening to charm outside of the ui
you wouldnt use charm there, you can have something like useEntity(Player)
and useComponent(Player, Health)
that would subscribe to the state and update it
but that will be everytime you want to use it
you mightve done that in react
because you cant expose UI state
Unknown User•5mo ago
Message Not Public
Sign In & Join Server To View
couldnt you have the health component or something, I dont use jecs so I wouldnt know
Unknown User•5mo ago
Message Not Public
Sign In & Join Server To View
I think you should be able to get one specific state like, health
Unknown User•5mo ago
Message Not Public
Sign In & Join Server To View
you create a state, and do setState() with your health
Unknown User•5mo ago
Message Not Public
Sign In & Join Server To View
you query it, dunno how it works, but maybe subscribe every frame and update it or however you consume state
it would be a hook, so can be abstracted
and its only done once
but react, react is more strict with that, and the ui state is locked in react, and hidden
(for a very good reason)
Unknown User•5mo ago
Message Not Public
Sign In & Join Server To View
but it would only update it if it actually changes?
I mean its a number
Unknown User•5mo ago
Message Not Public
Sign In & Join Server To View
Immutability
ya thats better in na immutable approach
but ig its a different pattern
Unknown User•5mo ago
Message Not Public
Sign In & Join Server To View
you get what I mean right 🧐
Unknown User•5mo ago
Message Not Public
Sign In & Join Server To View
it's not about performance
not performance, its more of an antipattern
easier to debug, the state is pure
theres no side effects
all of that
Unknown User•5mo ago
Message Not Public
Sign In & Join Server To View
maybe it something about jecs
Im pretty sure in matter is easy to just query one part of the state
i reacted with facepalm because you said "I get what you are trying to say now yeah" and then proved that wrong in the next sentence
ok maybe i missunderstood mb
Unknown User•5mo ago
Message Not Public
Sign In & Join Server To View
oh mb
Unknown User•5mo ago
Message Not Public
Sign In & Join Server To View
ya, I mean I said its "whatever" it might not be a problem, specially if your ui is small
but yeah its backwards
XD
Unknown User•5mo ago
Message Not Public
Sign In & Join Server To View
you totally right 🙌
Id say so, the other person that did the same approach
also used ecs XD
Unknown User•5mo ago
Message Not Public
Sign In & Join Server To View
yeah you shouldnt use reflex for that
thats even worse
you'd have duplicated states
Unknown User•5mo ago
Message Not Public
Sign In & Join Server To View
same with vide sources or charm atoms
nah, sources are for ui, atoms for outside
isn't he just creating a big file with vide sources
if you mean the "proxy" that is used to connect your atom
and updating em from his code for ui to react accordingly
Unknown User•5mo ago
Message Not Public
Sign In & Join Server To View
ya but hes updating those source from the jecs code
Unknown User•5mo ago
Message Not Public
Sign In & Join Server To View
might be some problem with ecs 🤔
I was under the impression that accessing entity states was easier
Unknown User•5mo ago
Message Not Public
Sign In & Join Server To View
ya, and even if you query components, its probably gonna be every frame
I actually dont think there are better solutions .-.
Unknown User•5mo ago
Message Not Public
Sign In & Join Server To View
I see what you do this
I apologize 🙏
Unknown User•5mo ago
Message Not Public
Sign In & Join Server To View
no no, same I hope I wasnt rude
I mean, that might be one thing
its just more flexible
Unknown User•5mo ago
Message Not Public
Sign In & Join Server To View
react is more strict
Unknown User•5mo ago
Message Not Public
Sign In & Join Server To View
in your opinion guys
Unknown User•5mo ago
Message Not Public
Sign In & Join Server To View
is using ecs in roblox comes down to preference, considering these problems
it is, because it becomes too opinionated
i've never really used ecs before, i was considering looking into it
just wondering if it's worth it
Unknown User•5mo ago
Message Not Public
Sign In & Join Server To View
ah, i see. i'll look into it one day 🤔 mb if i was a bit rude, guess it comes down to these ECS-related problems i don't really understand 😅
Unknown User•5mo ago
Message Not Public
Sign In & Join Server To View