Download

4.9 Transition Guide

Dear Community,

It is that happy day once again!

Yay for 4.9!

This thread is a place where you can post your research / ask questions as you upgrade your code bases to 4.9.

Feel free to post compile errors you’ve solved or 4.9 errors / issues that you have not yet figured out so we can all do this process together!

:slight_smile:

Rama

All FHitResults Now Return The Distance From Start To ImpactPoint

Dear Community,

This is one of my accepted pull requests!

All FHitResults now have a property Distance that gives you the non-squared actual distance from the trace start to the impact point!

I saw that PhysX was always returning this info and submitted the code to Epic to expose this valuable information.


**You Can Improve Performance of Your Game Code Now**

You can refactor a lot of code that had to use distance squared checks and separate distance calculations to just use FHitResult:: Distance now!

**This will actually improve the performance of your game code!**




```


/**
 * Structure containing information about one hit of a trace, such as point of impact and surface normal at that point.
 */
USTRUCT(BlueprintType, meta=(HasNativeBreak="Engine.GameplayStatics.BreakHitResult"))
**struct ENGINE_API FHitResult**
{
	GENERATED_USTRUCT_BODY()

	/** The distance from the TraceStart to the ImpactPoint in world space. This value is 0 if there was an initial overlap (trace started inside another colliding object). */**
	UPROPERTY()
	float Distance; 


```



Enjoy!

Rama

Woohoo, lets get this 4.9 Upgrade Party going =)

Converting FLinearColor to Color

If you want to convert a FLinearColor to a FColor, you must now use



.ToFColor(true)




Color.h

/** Quantizes the linear color and returns the result as a FColor with optional sRGB conversion and quality as goal. */
	CORE_API FColor ToFColor(const bool bSRGB) const;

private:
	/**
	 * Please use .ToFColor(true) on FLinearColor if you wish to convert from FLinearColor to FColor,
	 * with proper sRGB conversion applied.
	 *
	 * Note: Do not implement or make public.  We don't want people needlessly and implicitly converting between
	 * FLinearColor and FColor.  It's not a free conversion.
	 */
	explicit FColor(const FLinearColor& LinearColor);



**BodySetup Include**

To get the definition of UBodySetup you must now include



```


//Body Setup
#include "PhysicsEngine/BodySetup.h"


```



PhysX Engine

PToU Conversions moved to PhysXPublic

The PToU conversion got moved from PhysicsPublic.h to PhysXPublic.h


**BodySetup::TriMesh -> TriMeshes**

Trimesh is now an array in BodySetup!



```


#if WITH_PHYSX
	/** Physics triangle mesh, created from cooked data in CreatePhysicsMeshes */
	TArray<physx::PxTriangleMesh*> TriMeshes;
#endif


```

//GameMode Errors

PreLogin & InitNewPlayer override errors.
argument changed to “const TSharedPtr<const FUniqueNetId>& UniqueId”

Just need to add the “const” to overridden function that includes FUniqueNetId.

–Spawning function Deprecated, UGameplayStatics::BeginSpawningActorFromClass

Old: BeginSpawningActorFromClass()

Replace with: BeginDeferredActorSpawnFromClass()

Spawning Actors with Collision Override replaces bNoCollisionFail

Dear Community,

As of 4.9, in World.h, there is a new enumerator for handling collision of newly created actors:



/** Defines available strategies for handling the case where an actor is spawned in such a way that it penetrates blocking collision. */
UENUM(BlueprintType)
enum class ESpawnActorCollisionHandlingMethod : uint8
{
	/** Fall back to default settings. */
	**Undefined	**							UMETA(DisplayName = "Default"),
	/** Actor will spawn in desired location, regardless of collisions. */
	**AlwaysSpawn**								UMETA(DisplayName = "Always Spawn, Ignore Collisions"),
	/** Actor will try to find a nearby non-colliding location (based on shape components), but will always spawn even if one cannot be found. */
	**AdjustIfPossibleButAlwaysSpawn	**		UMETA(DisplayName = "Try To Adjust Location, But Always Spawn"),
	/** Actor will try to find a nearby non-colliding location (based on shape components), but will NOT spawn unless one is found. */
	**AdjustIfPossibleButDontSpawnIfColliding**	UMETA(DisplayName = "Try To Adjust Location, Don't Spawn If Still Colliding"),
	/** Actor will fail to spawn. */
	**DontSpawnIfColliding**					UMETA(DisplayName = "Do Not Spawn"),
};


So this



SpawnInfo.bNoCollisionFail = true;


becomes this



SpawnInfo.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;


Enjoy!

Rama

Thanks!
Getting projects ready for the transition :slight_smile:

Ditto on RegisterPlayer override (GameSession function).

Hey Rama,

Do you mind extending your tutorial ( A new, community-hosted Unreal Engine Wiki - Announcements and Releases - Unreal Engine Forums ) including this change? I’m confused how to apply it.

Thanks in advance!

Okay I’ve now updated my Traces wiki to 4.9.0 !

I include examples of how to use the new FHitResult Distance property that was my pull request to Epic.

Trace Functions in UE4

Using Distance Property of FHitResult

Enjoy!

Rama

What does this mean?

“New: AIController class now derives from IGenericTeamAgentInterface which will make team-handling easier in the near future.”
“If your game-specific AI controller class already derives from IGenericTeamAgentInterface, you probably should remove it from your controller’s parent classes”.

So confusing… what specifically do I need to remove? Do I suppose to unassigned my AIControllerClass from my controller? What the heck?

I’m also getting engine’s compile error:

Does this have to do with it?

Sorry, my fault. I had #define NoTeam] somewhere in my code and it conflicted with the UE4.9’s GenericTeamAgentInterface.

Took hours to dig through to find it though. :confused:

ps. Another question, PostProcess’s Settings.Blendables is now depreciated and cannot be accessed. So how do I clear all its array? Using Settings.SetBaseValues() seems to remove everything, not just the blendables array.

To declare a USoundCue pointer like this:

you will need to add the #include “Engine.h”

The removed “EnableParent” in the tick function.
Instead of it, you should enable/disable the tick in each component.

In Scene.h



//FPostProcessSettings Struct

/**
	 * Allows custom post process materials to be defined, using a MaterialInstance with the same Material as its parent to allow blending.
	 * For materials this needs to be the "PostProcess" domain type. This can be used for any UObject object implementing the IBlendableInterface (e.g. could be used to fade weather settings).
	 */
	UPROPERTY(EditAnywhere, Category="PostProcessSettings", meta=( Keywords="PostProcess", DisplayName = "Blendables" ))
	FWeightedBlendables **WeightedBlendables**;

	// for backwards compatibility
	UPROPERTY()
	TArray<UObject*> **Blendables_DEPRECATED**;


So you’ll simply be clearing the WeightedBlendables array instead!

Enjoy!

Rama

4.9 Transition Plan:

  1. Backup 4.8 project
  2. Open up / convert to 4.9
  3. Notice that “build lighting” never finishes, in any project
  4. Remove 4.9 and keep using 4.8 until 4.9.1 is out

Where does const get added to the line? i.e. what should this line read?
virtual void PreLogin(const FString& Options, const FString& Address, const TSharedPtr<class FUniqueNetId>& UniqueId, FString& ErrorMessage) override;