- This might be something you learn sooner or later as you are coding…..even if your space complexity is the same, some methods are still better than the other ones and there is a reason why some method is preferred more than others
- For example, array is always going to be better then hash map. As hash map are likely built with a larger size array as a base to make sure they got space for all the potential inputs
- You can write all the code you want to integrate ChatGPT to your project, and it seems like free tier also has some capacity to use. However, it will not work until you put money in.
- I wonder if it used to be ok, then the pricing chanced without all the documents updated
- When making a project with LLM in mind, make sure you think about business model since every query costs
- Suck up! does a pretty good job about it
- It might be better to use LLM for something more lengthy and fancy, or rewrite lines into different flavor/personality
- By putting your definition of relationship between variables into code makes things faster as you skip the conversion of A->B (if applicable), but it also limits the possibility of extending the function. Pick whichever that fits the need.
- Edge AI looks pretty interesting, it should provide a better distribution of LLM model to games without needing to be always online
- It probably will be with embedded system first
- Before being part of the game, it is likely to go through a few generations
- Probably still need a few year done the line for it to be part of PC…but console might be able to have it in the next generation? If this happens, PC game and console game will separate til PC catches up, vise versa
- If it really is used in game, that means we can no longer have the same-same experience for everyone, but it should be fine as long as it is used for not-lore important elements, just like LLM.
Category: UEFN
-
[May 2025]short note
-
[Feb 2025]Misc Note for Coding
Busy
UEFN Verse:
- No abstract instance allowed. All devices must exist in the map as actor in order to function
- Prop Manipulator only calls on harvest when it is damaged by an axe AND when the prop manipulator think there are still resource in this node
- To make infinite resource node, override the resource and then you can set the resource given to 0 so it never decrease
- If your Prop Manipulator is controlling a blueprint, OnHarvest would not be called if the blueprint is set to not drop resources
- The default cube doesn’t seem to have right UV……not big deal but it make it not idea to use when doing material work while waiting for the model
- The default blueprint asset is a big pink glowing cube. If you are making particle effects with blueprint assets and see that, that means you didn’t setup that particular asset
- Material can do some cool thing to rotate the model, but it doesn’t seem to like the animation controller (or the basic cube has something that messed it up, like bad UV map)
- I really want a way to properly make a function fail instead of doing something like 5/0 or Mod[10,0]
- When you are doing material work in UEFN, there are something special when it come to sizing the object from material
- If you are using the material in blueprints, make sure you check “Evaluate World Position Offset” to be true. Otherwise the sizing function for the material will fail
- Want to reference material in verse? put them in Materials folder and you can reference it as “Materials.MyMaterial{}”
- Want to organize it in folder with in the materials folder? Declare modules in Verse such as below:
- TopLevelFolder<public>:= module:
SubFolder<public>:= module:
- TopLevelFolder<public>:= module:
- Then you can access it as “TopLevelFolder.SubFolder.MyMaterial”
- Want to organize it in folder with in the materials folder? Declare modules in Verse such as below:
- Sound device does not have the feature to play sound on location (not the same as play to an agent), it also doesn’t have the feature to set the sound in the Verse. You need a lot of sound device if you want something to fire different sound in different situation AND you want multiple players to hear
- Technically, you can collect players who are close to target location and play to them in Verse, but it doesn’t really give you directional information if you care about that. Regardless it does work but making more sound device and make them play when right condition is met individually is still an easier/more native solution
- The solution of teleport the sound device to target location and play has issue when the same sound is being triggered multiple times, since it can only be played in one location.
- FindCreativeObjectsWithTag is bugged in npc_behavior?(need to verify that)
- Analytics require an agent when they fire event, which make things a bit strange. Say we want to know if no one have enter/interact with something, the right way is putting analytics device on every other option, which can be a lot depends on the game
Unity:
- I was just amazed by the input manager, but after looking into it a bit more. There are actually things that is pretty easy that it doesn’t cover/require extra setting
- For any key press input, it doesn’t have a way to tell when you release it. Even with the one that does detect release, it calls the same function as it is pressed. If you want to track press/release with one input, you need an extra bool to remember which one is which. Pretty redundant.
- Another way is use 2 input: one calls for press and the other one calls for release. Still redundant but more reliable and safe in turns of edge cases
- It used to be able to set hold time for each input, doesn’t seem like it anymore
-
[Jan 2025]Misc Note for Coding
Changing the title as I will be including notes not just for verse
UEFN Verse:
- No global leader board….! I am surprised that it is still not a thing for verse
- Right now the way is to have a community for people to post their stat so the creators add it manually in regular update
- I don’t understand the reason you need weak_map(session, t)…unless you can access other sessions? Otherwise it is the same as local
- Turns out that is THE way to make global variables
- Epic remove global variables and force everyone to re-make them with weak_map
- map of a map if you want to have a map as global variable….yikes
- For global variables, the main reason thar it has to be weak_map(session, t) is because module scope require weak_map, which is used to create persistent data
- Conditional button doesn’t fire event when people put require items in them. It usually is not an issue if you have “All key items required at once” is true, but when it is false you will want that event fired
- The way to do it right now is using a button to trigger conditional button so you know when the button is pressed
- Barrier device no longer load on far distance 😦
- Even though you can block the gun fire, it doesn’t block axe, keep that in mind if you want to use this device to block damage to something
- Item on ground despawn naturally when there are too many items in the world. In a map that we allow player dropping item and also have resource spawn into the world as item. Some resource will be removed randomly
- It will be great to have a list of items will never despawn in island settings, or just make them higher priority so we despawn other item that we care less about first
- Item spawner only spawn one thing in the item list. When you call the function “cycle to next item”, it will remove the previous spawn
- Using ToolTip in verse actually cause UEFN to crash, not sure when that started
- The actual way to use it is this:
- @editable{ToolTip:=TestToolTip} MyVariable : logic = true
- Prop manipulator device only fire harvest event if the resource is overridden
- Editable doesn’t support map container, really should imo
Unity:
- New input system is pretty good, but you totally need to go through videos to learn it since they are quite a few steps. Patient pays well.
- Sometimes a function is grey out as “it is not used”. That isn’t true. Be confident if you are following your video right.
- EulerAngles are clamped from 0 to 360. Even when it make sense to have it over this range.
- Delta time is not consistent
- No global leader board….! I am surprised that it is still not a thing for verse
-
[Dec 2024]Misc Note for verse
- Lighting in UEFN can be really different based on the platform. Console seem to have issues compare to PC
- Stat Management Devices just got added in 33.00, should take a look
- Use props to make in-world UI might be a better idea than trying to use widget
- I don’t understand the limit of making some device not available for certain projects
- State Creator Device is bottom based, as the Tracker device is top-left based
- It moves elements to the lower part of screen, but if you have elements in different Y height, the higher one can move up
- Still, since the anchor is bottom-left based, it will “broke” as soon as someone changed their HUD scale
- You can’t have 2 of those and wanting them to track the different stats together
- Doesn’t seem it can go away, not like HUD device that you can hide it. The best way to “hide” it is making elements invisible in the widget
- When setting stat for players, set level, then value
- The best part of this device is that you don’t need to do the logic of “rank up”/”level up” to reset the value. You can just give them the value and it handle those for you
- What does “Show Widget in List” mean?
- It allows the widget to be full screen overlay
- Also allows multiple stat HUD to be shown on screen
- When “Show Widget in List” is true, the stats with the name scope will be displayed based on HUD priority; when “Show Widget in List” is false, it will be shown to player regarding the HUD priority
- Sounds like a bug…the tooltip didn’t mention this effect, but we can use it
- Switch device, GetCurrentState doesn’t return a bool but void. When the result is ON, it successes, fail if OFF
- This is how to use GetCurrentState function to check the state
- if(SwitchDevice.GetCurrentState[Agent]):
- if(not SwitchDevice.GetCurrentState[Agent]):
- Code below will not work
- if(SwitchDevice.GetCurrentState[Agent] = true):
- This is how to use GetCurrentState function to check the state
- Is HUD priority different from Z-order?
- get player from agent, get fort_character from player, get agent from fort_character
- Tracker device track default stats, such as elimination, but it won’t track custom stats you create from stat creator device
- Stat Counter can track your custom stat, can also track default stat
- Broadcast Events on stat change, how to capture those events in verse?
- the counter do comparison to a const value set to the counter device
- This device can server as a way to manipulate stat values with overwrite settings
- Cinematic device won’t play if the target player is too far away from the cinematic
- Can’t use <decides> and return logic, is it because they are somewhat redundant?
- Always use return for your function, just a good practice
- Some function you can set your return value by just put the value as the last line, but it will cause issues when the return type is logic
- For verse logic that will happen when player join during game, always assume agent/fort_character can be invalid and use a loop to wait dynamically til those 2 are valid
- When you need player name:
- MessageName<localizes> (Agent:agent):message= “player name is {Agent}”
-
[Nov 2024]Misc Note for verse
This month is a busy month, hopefully I still remember must of the things…
- When you has a suspended function, or anything that is checking a reference of player, prop, or anything that can be removed in the game. You want to always check if they are still valid before using them.
- Especially player, since they can join/leave the game as they like.
- Bugs that doesn’t make any sense can happen
- Prop manipulator has a small sphere, and the props it is interaction with must touch that sphere.
- Prop manipulator kept the prop alive in its best ability. That says, if it is destroyed (for example, if it can be damaged and player deal enough damage to destroy it), the prop will be removed from the game and the prop manipulator can no longer recover it
- You must connect to UEFN to see verse debug logs
- I wish this wasn’t the case
- HUD device bug:
- “Re-Evaluate Message On Show” should force the device to treat same message as different, but it turns out that it doesn’t do that
- Since you can set it up so Show() trigger some animation, we need it to always treat it the same as new message to make sure the animation is consistent
- Reading it as a bug since if you have multiple device taking individual messages, it will be fine. It only “fail” when there is only one device
- Example that works, as the entre animation will be triggered:
- DeviceA.Show(messageA)
DeviceB.Show(messageB)
DeviceC.Show(messageC)
HideAllDevice()
DeviceA.Show(messageA)
DeviceB.Show(messageB)
DeviceC.Show(messageC)
- DeviceA.Show(messageA)
- Example that doesn’t work
- DeviceA.Show(messageA)
HideAllDevice()
DeviceA.Show(messageA)
- DeviceA.Show(messageA)
- When you got a map with player as key, you can make the value optional. Instead of removing it from the map, just set it to false. That should make sure the data are removed to avoid some weirdness
- New chapter for Fortnite usually introduce major bugs in creator map
- There is no PleyerSwitchWeapon Event for verse to listen to
- There is not really a good way to track what weapon/item player is on besides check it regularly…hopefully we will get something better later
- Direct binding on device: if you see it grey out and not changeable, that means it is other device bind to this one. To change that, find the other device and you will be able to change it
- for(I->C:ArreyName):
- This give you an element on array each loop with an index that goes up accordingly
- GetCreativeObjectsWithTag is deprecated, and it is not consistent with the result
- FindCreativeObjectsWithTag is a new function that replace the one above, and it might be consistent…should do more test for it
- Device broke in blueprint, what a shame…Hopefully that is what scene graph going to fix
- When you use FPS device or make a Lego map, there are devices that is default fortnite that might broke
- If your verse code logic is absolutely fine and it is still having bugs, especially inconsistent bugs. Look at the device you are using to see if anything might be related
- HUDMessageDevice.Show(Player) *could* show its HUD to other players if the recipient could include non-triggering player
- Note to self: init/reset value should happen as the first/last thing
- Device function can be called without a reference. In C++ terms, all functions from creative_device can be called as static functions
- As the result, if you didn’t have the right reference, the function will be called as it is newly made as default
- It won’t call OnBegin for the “newly made device”, means it is more likely they are static functions. However, they also have their own separate member variables. Maybe this is just a non-defined behavior that happen to be consistent
- This make it really hard to debug if you don’t know about it
- When you has a suspended function, or anything that is checking a reference of player, prop, or anything that can be removed in the game. You want to always check if they are still valid before using them.
-
[Note]verse – version 1
Epic just make an announcement about version 1 of verse. I am writing to note the changes and thoughts
The version 1 upgrade is not mandatory, you can stay at current version until Epic decides to stop the support. Ideally, you want to be on top of version, so upgrade asap in a different branch is probably the best thing to do. I don’t expect a new version to come up every other week, so it shouldn’t be too much.
- Failure in Set
- Set no longer allow failable expression
- Now you want to store the result from failable expression to a variable with an “or” keyword to store a default value when the expression fails
- This should be things more defined, but I wonder if we can do
set X = FailableExpression[] or default
instead of making a new variable
- Failure in Map Literal Keys
- I think the page got a typo on there sample code there. They probably mean
map{ExpressionThatCanFail=>Value}
as the old code that is allowed before version 1 - Another change to avoid more undefined behavior
- I think the page got a typo on there sample code there. They probably mean
- Mixing Semicolon/Comma/Newline Separators for Blocks
- I was surprised to hear they allow mixing separators in the first place. Just more change to avoid ambiguity
- Sometimes we use new line to separate code that is too long, not sure if this impact that
- It really is pick your medicine. I am not bothered which way they do it as long as it is consistent and not ambiguous
- Might want to write down the result once I have project upgraded
- Unique Specifier Changes
- <unique><computes> is no longer allowed, now <unique> requires <allocates>
- <unique> – When a class is unique, you can make 2 instances with the same value and they are still not equal to each other
- I am not sure what to make of this bullet point since <computes> doesn’t seem to be a class specifier
- <allocates> is not on the specifier document yet?
- If <unique> requires <allocates>, and <allocates> is new. Why don’t just add the feature <allocates> is doing into <unique>?
- Function-Local Qualifiers
- now you can make variables as local with (local:) in case there is another variable with the same name but from outside of scope
- Personally speaking, you shouldn’t need this since you should name variable in a way that is clear and not duplicate…usually
- Are they trying to allow verse coding library? One use I can think of is allowing utility code library to be shared. Therefore, the code library will want to make sure they are using local qualifier so the project won’t mess with library if they have any global variables. I would love to have utility libraries.
- Public Fields in Structs
- Using <public> is no longer necessary
- Small and nice QoL improvement
- Failure in Set
-
[Oct 2024]Misc Note for verse
Here is what I learn from recent work using UEFN
- NPC behavior doesn’t seem to have a good way to access player information. A better way for it will be use a device since they have access to GetPlayspace().GetPlayers()
- found a way to do it….create a empty device like device{}, and call GetPlayspace().GetPlayers() on it
- You want to have <transacts>with the function in order to have it be allowed to call inside a if condition.
- When a function return logic(bool for Verse), the right way to call it in if condition will be if(func() = true), that is because a logic doesn’t become a condition in verse. You must specify them.
- For anything that could fail, they go to if
- I wish there are float_max or float_min, but no, just use some big magical number or define it to be global const
- player? is like a player pointer, with a question mark at the end means this variable can be null(in Verse, it is false instead of null). When use the value it stored, you want to use if since it could fail (when it is false)
- Use editable_number to limit max and min value on something can be changed in not just verse, but UEFN
- Expect default unit radius to be 50
- Only Guard NPCs are leashable. When you call leashable on non-Guard NPCs, it is a silent failure
- I don’t believe it should be a guard-only feature
- Should not be silent failure when try to leash on non-leasable, but the way for them to be set up in verse prevent any warnings
- No custom guard appearance allowed. To make custom NPC, use custom type
- It is unclear why it is not allowed, maybe it is but no one knows how to do that?
- When you have persistent data in a live game, all other branch must have those data as well. Or you will hit verse errors about unknown file, and your verse will compile locally!
- 1 tile is 512 cm
- To spawn particle effect, make a blueprint object with the particle component and the particle you want. Spawn the object as a prop and dispose them once the particle is done
- It feels like they should be a particle “object” as a prop that can carry a particle instead of need to have a blueprint
- pushback in verse: set arrayName += array {newElement}
- If your source control doesn’t know which file is what object, type the last 4 or 5 character on the file into the Outliner to find it
- There is no “for(int i = 0; i < something; i++)” logic, code it yourself some raw logic in verse to do this
- unbelievable lol
- if(prop.isValid[] = false ) <–don’t do that
- isValid returns a value of true or false, however =false is just checking if the function returns anything like a pointer since Verse treat false as null sometimes
- The right way to do it is
- if(not prop.isValid[])
- player.isValid is not the same as fortCharacter.isValid
- one of them returns false when player respawn, the other one doesn’t
- make sure you don’t use them interchangeably, gonna got strange bug that is difficult to figure out
- There is no Audio component, unless you drop a CUE(you can make it by right clicking a .wav file) in a blueprint.
- I don’t believe this is the intended way to implement audio, regardless this is the right way to do it at UE4
- Seems like the new right way is to use the niagara system, is this why it is no longer called particle system? as it can do audio and maybe other thing?
- Trust nothing….. prop can be invalid any time in the game, players as well. Make sure you take care of the case when things became invalid in your suspends function
- When use MoveTo function to move props. If your prop is huge (that include niagara range), it can crash even if your move to location is valid. Because the niagara system goes outside of playable boundary, it will crash and at this point Epic does not handle that. The error will look really confusing.
- Try to not have nested loop or race…it can be difficult to debug when something goes wrong
- NPC behavior doesn’t seem to have a good way to access player information. A better way for it will be use a device since they have access to GetPlayspace().GetPlayers()
-
[Note]How to do animated UI in UEFN (31.40)
So far there are 3 ways to create animated UI in UEFN, they all having its limitations. However, we should see what is to come in the December update as it seem to promise UI improvements.
update: It is totally possible with data binding, but there are still restriction- have a button, or anything that can be triggered by the UI itself
- This method seem good enough if the UI is interactable.
- However, it doesn’t works on pop-ups, or any in-game behavior feedback.
- in verse, creating the UI and remove the UI every tick
- Probably everyone’s nightmare unless you enjoy placing UI component in code
- Require you to add and remove the widget every frame for the animation
- At this point of the engine, cause memory leak and tank your game’s performance
- got some self-animated shader
- The easiest way to get something moving
- Doesn’t take any input or control
- Good for pop-up and the things that doesn’t communicate game meaning but just decoration
- Data binding (the best way so far)
- I am on 32.00 when I found out about this, but it is probably available before
- With different location of your UI, you want to use different device to do data binding
- If your UI is on top-left, use tracker device
- If anywhere else, you need to use HUD device with limitations
- The reasoning of this is tracker device being more powerful, but it force your UI to anchor on top-left. It might looks good on your machine, but it won’t work with people who changed their UI scaling. HUD device doesn’t have that issue, but it can only do very little data binding
- Once you linked your UI and the device to each other, go to the binding tab and create a new condition as “if expression, do queue animation”. In the detail of the condition, like the animation you want
- Right now it can only do Data compare float
- “if expression, play animation” seem to be a better way to set it up, but it actually doesn’t work
- When using tracker device, you can compare value(int) to the float value properly and use it to control many animations to play in different situations
- HUD device does not have any numbered value you can set from verse that is good as a switch for data binding since it only compare to float but not string/text.
- However, HUD device for some reason, the condition of “text equals to 0.0” seem to be always true regardless what the text is. For each HUD device, it will be able to trigger 1 animation and only when the text from HUD device is being updated.
At this point of the engine, animation in UI is possible. Regardless it is not good for giving feedbacks from the game. It is totally fine to have animated UI for the sake of art, or having fancy UI that require mouse clicks.
- have a button, or anything that can be triggered by the UI itself