How to center mouse cursor in Unreal Engine - unreal-engine4

I want to center mouse cursor. Here how I do it.
But here is a problem - when I change active window with alt + tab, cursor still in the center all the time. Can I check somehow that game window is focusable?

You can call IsForegroundWindow() on your LocalPlayer’s ViewportClient->Viewport.
Something like:
ULocalPlayer* LocPlayer = Cast<ULocalPlayer>(Player);
if (!LocPlayer->ViewportClient->Viewport || !LocPlayer->ViewportClient->Viewport->IsForegroundWindow())
{
// viewport is either not present or not in the foreground.
}
…should work for you. Player lives within the PlayerController, so the above code will work if called from within a playerController, or can be called somewhere else by grabbing the Player from the local playerController.

Related

How do I check whether I have changed rooms in Game Maker Studio 2?

So I have been working on a pause menu for a game I have been working on with Game Maker Studio 2.
Whenever I change rooms (like going to the options room or main menu) the pause menu stays and everything looks very weird and overlapped. Is there a way to check if I have changed rooms to destroy the objects the menu is made up of
(So like if (room has changed) {Delete pause menu})*
If someone could give me the correct syntax that would be awesome!
Thanks.
*I have sorted out deleting the menu, just need to know what to put in the if statement
For my game, I've done a check if the room is the same as the room in the main menu/options menu, or make a check that the pause menu only appear when it's not the main menu/options menu.
var roomname = room_get_name(room);
if (roomname != r_mainmenu && roomname != r_optionsmenu)
{
//draw pause menu
}
Another idea is to hide the pause menu once you go back to the main menu.

Roblox part appearing when clicked on another part

I need help, I have an idea for a game but one of the main mechanics does not work. I need when you click a part another part appears
Roblox part appearing when clicked on another part
You can detect when a player clicks the part by putting a ClickDetector inside of it, then a ServerScript in that same part which will have a variable that points to the ClickDetector, using the ClickDetector's MouseClick detect, you can use a :Connect() to create a new Instance("Part") in Workspace.
Example
Hierarchy
Workspace
Terrain
Camera
Part
Script
ClickDetector
Script
local clickdetector = script.Parent.ClickDetector
clickdetector.MouseClick:Connect(function())
...
local newPart = Instance.new("Part")
newPart.Parent = workspace
...
end)
I hope this helped, you should research the ClickDetector and Instance API references on the ROBLOX DevHub. Just keep in mind, if you don't give the new part a CFrame it will spawn at 0,0 in the world.

Making Cursor Mouse Always Enabled In Unity CardBoard Plugin

i think the title is clear , i want to make the mouse Cursor which is set in GazeInpuModule to be always enabled and in center of the both Left And Right Cameras , can anyone help me ?!
ive tried changing the GazeInputModule code to place the cursor in center , but got nothing !
Here's what worked for me:
Create a Cursor GameObject in the Head hierarchy
Add EventSystem in the project hierarchy
In the EventSystem Gaze Input Module component, ensure "Show Cursor" is selected.
In GazeInputModule.cs, PlaceCursor(), change the SetActive() to:
private void PlaceCursor() {
// ...
cursor.SetActive(showCursor);
// ...
}

Determining the location of a GTK widget on-screen to create a relevant popup window

I have a button labeled import (down arrow) and I am trying to determine it's location so I can create a popup menu to say 1. from device 2. from folder.
I can't seem to find anymore than allocation in the api docs, which is relative to the application window. Please help, I will send imaginary cookies ^_^.
using PyGI if it matters.
I figured out the answer before but couldn't self answer yet.
The process is as follows:
determine the location of the GdkWindow, which does not contain the window decorations.
: gdk_window_x, gdk_window_y
determine the location of the widget relative to it's GdkWindow
: widget_x, widget_y
x = gdk_window_x + widget_x
y = gdk_window_y + widget_y
as everything in the graphics world measures from top left (unless your weird :-)), you now have the location of the top left pixel of your widget.
You can get the position of the window relative to the screen using window.get_position(). Since you already know how to get the position of the button relative to the window, it should be a matter of adding up both to get the coordinates (relative to the screen) in which to place the popup.

are there DOM events for controller presses on the PS3?

I want to develop a site which is easy to use from a Playstation 3 PS3 game console web browser. I thought it would be good to make screen actions on button presses on the console.
I can find no information on how to do this after quite a bit of searching.
Any info or links highly appreciated!
Why not write a function that displays a message for every "keystroke" and you'll see what values they represent:
$(document).keypress(function(event) {
alert(event.which);
});
Then you can use the number you get from this test and create some logic based on that.
Like this perhaps:
if(event.which == 13) {
// display cool menu maybe?
}
From what I've tested so far, the left stick generates mouse events, left pad with arrows generates keyboard events corresponding to arrows, while the right stick generates a mouseevent but unfortunately it does not move the mouse, but rather scrolls the window.
I do not know how to detect in which direction the stick is pushed (unless the cursor actually moved or the background scrolled, in which cases it is quite trivial).
Check: http://vanisoft.pl/~lopuszanski/public/ps3/