Download

[HTML5 BP Nodes For You] Victory BP Library Plugin Nodes for HTML5 ♥ Rama

Dear Community,

I’ve spent most of my spare time for past 2 days researching a particular issue related to HTML5 developmenti n UE4, which is the issue that it is very hard to show/hide the mouse cursor at will when playing a UE4 game within a web browser!

My fundamental issue was being able to show hide the cursor when switching between UMG and regular gameplay, and the node I am giving you today does this!

I’ve finally generated a BP node that makes it easy for you to properly and definitively show/hide the mouse cursor at any time of your choosing, during runtime within an HTML5 game!

306cbfa66c07c8c9607672f884d139564557df11.jpeg


**Show Or Hide?!**

Yes the SetCursorVisible node will actually show or hide the cursor depending on the boolean value

1. If showing, the cursor is unlocked from the viewport / canvas
2. If hiding, the cursor is locked to the viewport / canvas

Please note there is a brief delay after the node is run before the new cursor state takes effect :)

Sometimes an extra click is required to resume hiding the cursor, which ties into the HTML5Application.cpp emscripten callback.

How Does It Work In Editor Builds?

The SetCursorVisible node will show up in-Editor but will not do anything unless your game is packaged for HTML5.

See my picture for the event you can write using my BP Library to show/hide the cursor for HTML5 OR regular UE4 games!


**Is HTML5**

I've written a C++ boolean check that you can easily make into a switch macro to perform unique BP Logic based on whether your game is currently running on an HTML5 build or is an editor/console build!

This allows you to use different Particle Effects / Lighting Settings / Quality Settings, or any other custom BP logic you want, based on whether the game is an HTML5 build or not!

Yay!

C++ Code For You

Here is the C++ code being used by my SetCursorVisible BP node, source code is included in my plugin download :slight_smile:



#if PLATFORM_HTML5_BROWSER
	#include "SDL_opengl.h"

	DEFINE_LOG_CATEGORY_STATIC(VictoryPluginHTML, Log, All);
	
	#include "emscripten.h"
	#include "html5.h"
#endif

void UVictoryBPHTML::VictoryHTML5_SetCursorVisible(bool MakeVisible)
{ 
	if(MakeVisible)
	{
		**#if PLATFORM_HTML5_WIN32**
		{
			SDL_SetRelativeMouseMode(SDL_FALSE);
			SDL_ShowCursor(SDL_ENABLE);
			SDL_SetWindowGrab(WindowHandle, SDL_FALSE); 
			UE_LOG(VictoryPluginHTML, Log, TEXT("SDL Showing Mouse Cursor"));
		}
		**#endif**
		 
		**#if PLATFORM_HTML5_BROWSER**
		{
			emscripten_exit_pointerlock(); 
			UE_LOG(VictoryPluginHTML, Log, TEXT("Exiting Pointer Lock"));
		} 
		**#endif**
	}
	else 
	{
		**#if PLATFORM_HTML5_WIN32**
		{
			SDL_SetWindowGrab(WindowHandle, SDL_TRUE);
			SDL_ShowCursor(SDL_DISABLE);
		        SDL_SetRelativeMouseMode(SDL_TRUE);
			UE_LOG(VictoryPluginHTML, Log, TEXT("SDL Hiding Mouse Cursor"));
		} 
		**#endif**
		 
		**#if PLATFORM_HTML5_BROWSER**
		{
			emscripten_request_pointerlock ( "#canvas" , true);
			UE_LOG(VictoryPluginHTML, Log, TEXT("Entering Pointer Lock"));
		} 
		**#endif**
	}
}


Happy Holidays!

Enjoy!

:heart:

Rama


**Latest plugin download on the UE4 Wiki: (7.16 mb) **
https://wiki.unrealengine.com/File:VictoryPlugin.zip

Not using the latest engine version? Check out my wiki section on which plugin release dates go with which engine version!

**Plugin Release Dates and UE4 Engine Versions**
https://wiki.unrealengine.com/Rama%27s_Vertex_Snap_Editor_Plugin#Plugin_Release_Dates_and_UE4_Engine_Versions

Victory Plugin Binaries for Packaged Games


**Victory Plugin on Media Fire**

**If your browser is not updating the Wiki download page** to the most recent version, you can use my alternative Media Fire download link!

Please note the mediafire version includes both the editor and packaged game binaries in the same file ♥ Rama

https://www.mediafire.com/?ieovbd5l9d7yub2

Donations

Donations can be sent to me via:
http://lightningfitness.org/donate/

Hello Rama.
I am getting a incompatible - missing error after restarting UE4.11.2
4a314366be9a2a67c5c06e54640f063c854d4c84.png
What do i have to do?