Difference between revisions of "Oni2:UnrealOni/Documentation"

From OniGalore
Jump to: navigation, search
(For now I don't think I will post here all functions and variables. Only a few examples. If there are more, there is github to dl the project.)
(A few notes on physics and gravity.)
Line 164: Line 164:
Dev notes: the rotation parts can probably by recycled for cheat code '''''munitionfrenzy'''''. <!--use loop for increasing the angle-->
Dev notes: the rotation parts can probably by recycled for cheat code '''''munitionfrenzy'''''. <!--use loop for increasing the angle-->
Set '''''Simulate Physics''''' and '''''Enable Gravity'''''
: In blueprint of object > Viewport tab (while mesh is selected) > Properties panel > Physics tab
Set '''''Simulate Physics''''' and '''''Enable Gravity''''' with '''Blueprints nodes'''
: ''Set Simulate Physics'' and ''Set Enable Gravity''
: If you disable '''''Can Characters Step Up On''''' via a Set node the object is still '''kickable'''.
: These settings are interesting for pickup items such as '''powerups''' and '''weapons'''.

Revision as of 15:58, 10 August 2019



Unprocessed files like PNG can be imported by drag and drop in the Content Browser.

They will be saved as .uasset in the folder you dropped the original file.

Mouse cursor

User widget with mouse cursor texture
Assigning a new mouse cursor

Tested in version 4.18, 4.22

  • create a png with transparent edges, import it
  • create a user widget, open it
  • drag and drop the mouse cursor asset into the widget designer
  • make it 32x32 in size 0, 0 in position
  • compile and save
  • open project settings
    • Engine > User Interface > Software Cursors
    • Add a new software cursor with "Default" option and pick your newly create cursor widget as map element.
The cursor might act strange in the editor's play mode. This should go away as soon as you test it via Lunch.
Finetune the widget image by moving it in the upper left corner. If its size is 32x32 then use the half (16) for the X and Y positioning.
Note of warning: DPI scaling doesn't seem to affect the mouse cursor at all.

User Input

Key binding

Key binding

You can bind actions to key (or other inputs) by going into Project Settings > Engine > Input.

Multiple keys for one action are also possible.

Note how movements use a scale for allow for eventually different direction values.


Double check: Input like key presses shouldn't be consumed by a character because characters can be replaced while playing.

The logic should be stored inside a controller otherwise you have to duplicate a lot of code inside all the characters, not to mention to keep that code up to date.

Movement controls might live inside the character BP.
Player-specific controls like opening the help menu should be inside a controller.
  • Create a new AI controller, name it something like OniPlayerController
  • Select the character in the world outliner or viewport, Ctrl + E to open the BP
  • Search for "Controller" and set the "AI Controller Class" to the new OniPlayerController
  • Add logic to the player controller (see Pause game)

Ignore inputs and pause game

Pause game

Since F1 is used to switch into wireframe mode in UEditor, we will bind # to pause the game as we need the regular keys (any letter of the alphabet for the cheat code input).

Normally key inputs are ignored when the game is paused.

In order to unpause the game we need to set the key to "Execute when Paused [x]" in the details panel.

Theoretically a flipflop could be used to register the second key input but the game could have been paused by other means so it is better to use an variable here. Luckily Unreal provides just that as a boolean node.

To let the game behave like a typical game pause inputs for character move and look are ignored. This is actually redundant as the game is paused.

We can recycle those ignore nodes later for game menus that don't require the game to pause.

Cheat codes

Find longest cheat
Detect cheats

Unreal has a Cheat code class but that doesn't ship with cooked games.


Also, to detect combinations of keys pressed ("shapeshifter", "lifeforever", etc.) we would have to write our own code anyway.

Instead of detecting each key press individually we can use the Any key event and then get key names, mostly capitalized letters for standard alphabet characters.

The letters will be stored in a string which we will keep at a maximum length of the longest cheat. The string is then compared against an array of cheat codes.

The string is cleared as soon as a cheat is found. A case select a.k.a. switch node can handle the different cheat functions.


Slow motion cheat "carousel"

Carousel uses the "Set Global Time Dilation" node and that's it.

Other games usually have a smooth transition from normal play speed to slowmotion and vice versa, but that is not the case for Oni.

If we really wanted to we could add a timeline node for a smooth transition.

Also, fast mode could probably be bundled with this function.

Character scaling

Behemoth function with scaling parameter (recycled for other character scalings)

This is basically one function with two free parameters, one for the scaling and one for the cheat name.

The central property in this code is the Actor Scale 3D for which we will set the scaling as following:

  • minime (0.5)
  • behemoth (2)
  • godzilla (4)

For toggling we need some checking on what is active. Booleans can work but with more different scaling more booleans are needed.

Instead we use read the current "Actor Scale 3D" via "Get", break that vector to floats and compare the X one against of our new scaling float.

If the input has the same value we will reset the scale to 1, bringing the character back to normal size.

The second parameter for the cheat name is purely decorative, it is only for the status message.


Jump cheat "Kangaroo"

For higher jumps we need bigger values for the "Jump ZVelozity" node.

In Oni jumps have a jetpack timer: the longer the jump action the higher the character will be eventually.

That feature is very important for the "marypoppins" cheat.



Live scripting

Dev console (construction)

In Oni you can do some scripting with the developer console.

We probably should also allow to call functions and set some variables like ai2_chump and chr_debug_characters = 1.

This requires a user widget and a key binding which will be # + Alt by default.

The ^ sign is a bad choice as it is not consumed and will be added to the first character, making âi2_chump an invalid command.
The dev console will not require a cheat in order to activate it on key press. While developing this test it won't make sense to restrict its access.

The widget is created by the player controller and attached to the viewport.

Alt + # will toggle the visibility and makes the input box ready for typing.

The text box has a On Text Committed where inputs can be processed.

Clear Keyboard Focus on Commit was set to False in order to allow repetitive input.

Todo: Use = sign and spaces as separator and a select node to handle the different variables and functions.

Sample functions and variables

Function ai2_chump

ai2_chump spawns a character, always face-to-face and 100 units away.

A better "chump" character is meant to implemented later, matching player's team id.

Also, the attached ai2_followme is not implemented yet.

Dev notes: the rotation parts can probably by recycled for cheat code munitionfrenzy.




Set Simulate Physics and Enable Gravity

In blueprint of object > Viewport tab (while mesh is selected) > Properties panel > Physics tab

Set Simulate Physics and Enable Gravity with Blueprints nodes

Set Simulate Physics and Set Enable Gravity
If you disable Can Characters Step Up On via a Set node the object is still kickable.
These settings are interesting for pickup items such as powerups and weapons.