Print text to screen in Unreal Engine 4 - text

I want to log some text on the screen, but not to all actors at once. I have several ai car actors, which all have a Scene Capture Component 2D component, on which their camera view can be seen.
I want to print to that object, but I cannot find any suitable function for this purpose. I found different print/draw text functions, but their target is either HUD or Canvas or Context, or simply the main screen. I tried to cast to one of the target types that have a function for this operation, but it always fails since Scene Capture Component 2D is not a subclass of any of them.
Is that even possible to do what I want?
(I use Unreal Engine 4.25 version with Blueprints.)

Maybe a way to this would be to add a HUD to each actor and have a text as a UI widget in it. Then you could play the visibility and Value of that text to show what you need at any point.

Related

Is there a `HVBoxContainer` for Godot?

Think of an RPG game where you might need to present a list of buttons. A user might enter a room where they have to select from a series of options (buttons). Is there a type of container/panel that would show clickable buttons horizontally, but wrap if needed?
The best analogy I can think of to picture the situation is, Imagine needing to click on an item in a backpack, but each item is potentially a different width. (I can make them all the same height but the width then varies)
.---[My Backpack]------.
| aaa bbb cccc ddd |
| ee fff g |
| |
| |
`----------------------'
(The options come from a database, so its unknown at compile time how many options might be in a room, so I am going to need to programmatically add options.)
The very bottom of this godot document introduces custom container layouts, but it's unclear to me how this would work in practice
Flow container for Godot 3.5 or newer
Godot 3.5 (currently in beta) introduces HFlowContainer and VFlowContainer that will serve the propuse described.
The HFlowContainer will fill a row and when they overflow, it will add a new row and continue there. The VFlowContainer will work on a similar fashion but with columns.
Flow containers before Godot 3.5
For older versions of Godot you can use the HFlowContainer addon which you can find it in the asset library (here). Note that there is no VFlowContainer counterpart.
As everything on the asset library it is free and open source, so feel free to read the code and modify it, which can be serve as starting point if you want to make your own custom Container.
Making your own custom Container
The gist of making a custom Container is that it must position its children.
For that effect you react to NOTIFICATION_SORT_CHILDREN in the _notification method. You might also want to react to NOTIFICATION_RESIZED.
You can have a method - which I'll call layout - that you call when you get the notifications:
func _notification(what):
if what == NOTIFICATION_SORT_CHILDREN:
layout()
And also call layout from the setters (setget) of the properties that define how the Container must organize its children. To call layout from anywhere other than _notification, you might want to use call_deferred("layout") to prevent any possible re-layout loops from hanging or crashing the game.
The layout method would iterate over the visible children Controls and use get_combined_minimum_size to figure out their size.
Something like this:
func layout() -> void:
# …
for child in get_children():
var control := child as Control
if not is_instance_valid(control) or not control.visible:
continue
var size := control.get_combined_minimum_size()
# …
Then using that information compute the position and size for the children Controls. When there is room for the Controls to grow, you may want to split it among them according to their size_flags_stretch_ratio.
Once you have the position and size for a Control decided, use fit_child_in_rect to position them, which will take into account grow and size flags.
Thus - barring the simplest Containers - you will need to iterate over the children Controls twice. And for that you might find useful to have an auxiliary data structure to temporarily store them.

How can I animate a Button entity from one place to another in ursina engine?

I am new to Ursina engine . I want to animate a button entity from one place to another using the animate_z method, but am unable to do so. Any suggestions?
Use animate_position(). animate_z will only change the depth, so you won't see the effect unless you have thing behind or in front, or if it's 3d.

Making and Object uniteractable

So I have a part of my game where the character is selecting an area of the map. And it opening up a panel. I have made it so that happens but an=m now stuck on the other part of it. I want only certain area of the map to be intractable, so that I can bar the player from selecting areas of the map that they aren't ready for. I have no idea how to make game objects in the game uninteractable. I have looked on Stack overflow, Youtube an d the Unity API to no success. Can someone help me with that.
How to make things un-interactable will vary depending on your situation. I'll be presuming that you're map is broken up into a grid of sorts.
The basic setup would involve a bool, probably called 'CanAccessZone'.
Then you'll need a class, to store any access info and popup logic, by popup logic I mean make the element either non-interactable or show a popup, with the shown popup being dependant on 'CanAccessZone'. This class can then be set up by your Map class when the level is loaded, or you could let the popup class grab the necessary values from the Map class.
If you're using Unity's UI buttons for the map pieces, then you could set interactable to false, until you want to let the player access the zone. If you want to display a popup informing the player that they can't access the zone, then your button will be interactable, but the click will delegate to your popup logic method.
It's a similiar principle if you're using gameobjects as buttons. You'd be using any of the OnMouse events to handle click events. https://docs.unity3d.com/ScriptReference/MonoBehaviour.html
Hopefully this'll lead you in the right direction.

How do I change the image rendered for just one eye?

I'm new to the google cardboard sdk. I need to draw a slightly different image for the left eye as compared to the right(I know distortion correction is taken care of). I saw the "Eye" class spec (an instance of which is passed to OnDrawEye()) from the docs.It does not seem to contain info of which eye is being referred to. How do I tell if the image is being rendered for the right or left eye and code accordingly?
In the class where you implements the CardboardView.StereoRenderer you have to define the function onDrawEye(), int this function you receive a parameter of type Eye, from that parameter you can know what eye is rendering at the moment with the function getType(). You can check the eye with the constants defined in Eye.Type

iPhone SDK building an Omnigraffle like app

I have been trying to find an example or some hints on how to create an app that I could drag, resize, rotate images onto a UIView and then save the individual pieces (including their size, rotation and placement) and the entire UIView into CoreData. Kind of like the omnigraffle app.
Any tutorials, examples or anything on any piece of the app would be greatly appreciated.
for dragging a view
http://www.cocoacontrols.com/platforms/ios/controls/tkdragview
for roting a view http://www.cocoacontrols.com/platforms/ios/controls/ktonefingerrotationgesturerecognizer
for resizing a view
http://www.cocoacontrols.com/platforms/ios/controls/spuserresizableview
What respects to core data, its actually pretty straightforward just, gather the classes in one view, see the properties you need to save, and the new one you will need for your app and thats it.
Like:
Object Canvas containing a many relationship to morphlingViews wich contain all the properties as center, color, width, height, angle, UIPath (if you plan to create custom shapes) layer position (so it gets drawn correctly) and if you plan to connect the views as omnigraffle add a many realtionship to self (in morphlingViews) so you can take the center of different morphlingViews and add a simple line between them. (and a string if you plan to add drawInRect method to allow users to write in the objects, then it will be a good idea to add the text properties as well).
You can also add Quartz Composer drawing styles properties to the object, as shadow, shadowColor, shadowOffset, or add patterColor to add resizable background.

Resources