CrazedFan Games
  1. Posts/

Notes: How do I make that work in Unreal Engine 5?

·8 mins

What should I do when I start a new Maya project? #

  • File > Set Project
  • Verify Units at CM to match Unreal Engine default
  • Verify Grid renders every 10.0000 – no subdivision needed
  • Enable grid snapping

How do I change the ‘Stop’ key when using Play-in-Editor (PiE) so I can bind Esc in my game? #

`Edit > Editor Preferences > Keyboard shortcuts> tab on the left » Under General Keyboard Shortcuts, search for the ‘Play World (PIE/SIE) drop down (or type ‘stop’ in the search), rebind the ‘Stop stop simulation’ key input.

How do you determine the speed of a projectile? #

Different weapons and bullets have different behaviors. A good way to get started might be to set speed to 79248. Resources on the Internet tell me a typical bullet travels 2,600 feet per second. There are 30.48 centemeters in a foot. 79248 = 2600 * 30.48.

How can I align blueprint nodes cleanly? #

In UE5, by default, you can press Q to straighten connections for selected blueprint nodes, You can also customize your shortcut by setting a keyboard shortcut in Edit -> Editor Preferences -> Keyboard Shortcuts under Graph Editor set a keyboard shortcut for Straighten Connections. Select nodes in your blueprint and hit that shortcut!

How do I keep the right scale? #

You can setup a preview mesh to give you quick in-editor feedback. Go to Edit > Editor Preferences then click All Settings and search for Preview Mesh. You should see it under Level Editor - Viewport. The default preview mesh is useful for color corrections. You can change it though to be any mesh you want. Unreal ships with a Manequeen. You’ll need to convert the skeletal mesh to a static mesh by right-clicking on the mesh and choosing the convert option. Once converted, you can select the new static mesh of the manequeen as your quick preview mesh. Press the \ backslash key to see the preview mesh in the editor as long as your camera is above the in-game window. You can import the mannequin into your project by following this YouTube video.

  • 1 Unreal Unit = 1 Centimeter
  • 100 Unreal Units = 1 Meter
  • 100,000 Unreal Units = 1 Kilometer
  • 1 Foot = 0.305 Meters = 30.5 Unreal Units

The average male height is 1.7 meters or 170 centimeters.

What are the units of measure for my game? #

  • Player Size: 192 units height
  • Door Sizes:
    • Single Door:
    • Double Door:
    • Garage Door:
    • Traffic Lane:

How can I change the gravity of my game? #

In the Project Settings, you can change gravity. A read somewhere a good approximiation of Half-Life 2 gravity in Unreal is -1143. The default gravity is -980.0.

How can I convert units from Source (Hammer) to Unreal Engine? #

Use 100/1.905 scale factor in HammUEr (52.49). Like you discovered, the conversion factor is 1.905 from Hammer units to the default Unreal unit of cm, because a Hammer unit is 1/16 foot. Pretty much all distance units in Source are Hu. So you can assume gravity is 60Hu/s. There are exceptions to this rule when it comes to interactions with the Havok physics engine, due to the internal conversion factor the engine uses. Using a series of mathematical proofs, you can determine the conversion factor there, but let me know if you need to know about that. It’s only really useful for gravity gun conversions and physics traps.

– Mastercoms (link)

How can players customize their inputs instead of using hard-coded bindings? #

https://couchlearn.com/how-to-use-input-actions-and-input-axis-mappings-in-your-unreal-engine-4-game/

How do I implement Gameplay Mechanics in Unreal Engine 5? #

The following are notes I’ve collected to help me research how I may implement some forms of gameplay mechanics within Unreal Engine.

How do I implement an Energy Field, an Ammo Pickup, or a Health Pickup? #

Take a look at Overlap Events. Overlap events enable you to trigger events when one object intersects with another. You fire an event when the interaction between two things begins or when that interaction ends. See [Collision Overview Documentation][collision].

Overlap volumes can be of various shapes. These volumes are typically made by attaching components to the actor – usually a box, sphere, or capsule.

How do I implement Physics Collisions? #

When objects are not allowed to overlap or intersect, you can make them collide. For example, imagine running into a bunch of cardboard boxes stacked up in a doorway. Hit Events enable the physics engine to calculate and apply forces to these objects. When this happens, you use the hit event to trigger a gameplay event. See [Collision Overview Documentation][collision].

How do I sometimes implement Physics Collisions and overtimes an Energy Field? #

When you need the option of either a physics interaction or an overlap interaction, take a look at Collision Presets. For example, something can be a physical barrier to one player and an energy field to another. You can use the properties of the object(s) to determine how they behave. See [Collision Overview Documentation][collision].

How do I calculate the line of fire for an instant hit like a railgun, laser, or many Call of Duty weapons? #

Bind a function to the fire button(s). In this case I have declared void FireWeapon(); with the following implementation which calculates the line of fire and draws debug line and point and renders particles where the weapon makes contact with a collision object.

void AMainCharacter::FireWeapon()
{
   	// ... other code omitted ... //
       
    // BarrelSocket is the name of the socket which is at the tip of the weapon and 
	// is intended to be the point where particle effects are emitted and 
	// fire lines are calculated from.
	const USkeletalMeshSocket* BarrelSocket = GetMesh()->GetSocketByName("BarrelSocket");

	// When firing our weapon, we need to calculate an impact or lack of one. We'll create
	// an FHitResult which packages hit information.
	FHitResult FireHit;
	const FVector Start{ SocketTransform.GetLocation() };  // Starting point
	const FQuat Rotation{ SocketTransform.GetRotation() }; // Rotation of the socket.
	const FVector RotationAxis{ Rotation.GetAxisX() };     // Get the vector of the X Axis which is the direction of the Socket pointing away from the gun
	const FVector End{ Start + RotationAxis * 50'000.f };  // Distance to trace.
	// Trace the vector and populate FireHit with information our contact, if anything.
	GetWorld()->LineTraceSingleByChannel(FireHit, Start, End, ECollisionChannel::ECC_Visibility); 
	
	if (FireHit.bBlockingHit)
	{
		DrawDebugLine(GetWorld(), Start, End, FColor::Red, false, 2.f);
		DrawDebugPoint(GetWorld(), FireHit.Location, 5.f, FColor::Red, false, 2.f);

		if (ImpactParticles)
		{
			UGameplayStatics::SpawnEmitterAtLocation(GetWorld(), ImpactParticles, FireHit.Location);
		}
	}

    // ... other code omitted ... //
}

Unreal Engine 5 Problems and Known Solutions #

Why can’t import assets into Unreal Engine 5? #

I had issues importing assets into Unreal Engine 5 when those assets were on a different drive from the project. In my case, I have a C:\ and a D:, and I installed Unreal Engine onto my C: and have my project assets on the D: Unfortunately, unreal only allowed me to import assets on the D: – same as my project.


Definitions #

Defining things helps me understand them. Enjoy the definitions:

What is an FRotator? #

A rotator is a collection of three floats that represent 3d space. Depending on the use it may represent either:

  • X, Y, and Z
  • Roll (X), Pitch (Y), and Yaw (Z)

A rotator is limited in the values it supports as these values represent degrees of rotation around each axis. Limits are between 0 and 360.

  • These values are valid: 100.0, 100.0, and 200.0
  • These values are invalid: -200.0, 10.0, and 415.0

So what? What does this mean?

Think about your head and how you use it and position it in space. When you tilt your side to side toward your shoulder you are adjusting the Roll. Positive values are to the Right. When you tilt your head up or down you change the Pitch of the rotator with positive being Up. Finally, when you rotate your head to turn right you increase the Yaw.

What is the check macro? #

Performs an asset that halts execution if the component is not valid.

What is the UPROPERTY? #

[uproperty][UPROPERTY] is a Unreal macro that makes C++ properties available to the Unreal Engine. You can specify access level such as read-only and where it can be read as well as make it writable. You then choose where the property should appear in blueprint detail panel within the editor.

What is DeltaTime? #

DeltaTime is the time between frames. A frame is a single rendering to the screen. A frame rate is the number of frames drawn to the screen during a second. A tick is often used to describe a frame – the game ticks once for every frame. Because performance varries between machines or moments as load on hardware demands change it is important that one does not rely on frames or ticks exclusivly. By calculating DeltaTime – or the time between ticks or frames – we can ensure consistent and reliable movement so things are smooth and consistent across machines or as load changes on a machine’s hardware.

So what? What does this mean?

DeltaTime is used to determine how much time has passed since the last render which allows you to make a consistent experience across hardware or changing load on hardware.

What is a Sound Queue? #

TBD

[collision][https://docs.unrealengine.com/4.27/en-US/InteractiveExperiences/Physics/Collision/Overview/] [uproperty][https://docs.unrealengine.com/4.27/en-US/ProgrammingAndScripting/GameplayArchitecture/Properties/]