Blueprint VS. Script

 While working with Unreal Engine 5 there is a constant ebb and flow with using blueprints. Learning when to utilize the power of blueprints is a true skill. Learning how to use blueprints and script at the same time is an even greater skill. I had a problem this week dealing with the use of a Widget on an actor in the world. The actor was meant to be an NPC the player can interact with and upon being a certain distance from the NPC the player will see the widget show up above the NPC's head. I ended up getting the widget working in blueprint and then set out to convert some of the visual scripting to c++. Things were going well until I started having uses with the widget displaying detached from the NPC. Nothing I did would change the location of the widget. The solution ended up being quite interesting.

The solution to this issue ended up being related to the type of widget I was using in script compared to the one I had tested in blueprint. The one I used in blueprint was a widget component and not a user widget. After realized my mistake I had to refactor the c++ script to accept the new type. Finally, I solved the issue. Well, actually not quite. The widget was still showing up in the wrong place. I did one final coparison between the blueprint I tested with and the new widget component I created and found a flag was not set properly in the editor. When creating the widget I set the size to be "Desired". If you use this option you must make sure the editor knows this.




Author: Zachary Giffin

Posted 19OCT23

Comments

Popular posts from this blog

Resolving the Flying AI Bug: Boundary Fix in Level One Environment

Paying attention to Details

Revamping the player's attacks