Unreal Engine: Difference between revisions
From Andreida
| No edit summary | |||
| Line 43: | Line 43: | ||
| === Logging === | === Logging === | ||
| The following is just a copy/paste/change from the UE4 wiki and was really done from different persons, I am just using the work of different people here. | |||
| In game output of your logging, like chat text: | |||
| Put it in a Log.h and put it into your <your_project>.h file before the #include "Engine.h". | |||
|  if (GEngine) | |||
|  { | |||
| ⚫ | |||
| ⚫ | |||
| <pre> | <pre> | ||
| // macros | |||
| bool log(FString sText) const; | |||
| // - LOG_LINE | |||
| // - LOG -> output log | |||
| // -- LOG("text"); | |||
| // -- LOG("text %s %f %d", "text", 1.2, 5); | |||
| // - print -> screen | |||
| // -- print("text"); | |||
| // -- print("text %s %f %d", "text", 1.2, 5); | |||
| #if _MSC_VER | |||
| bool  | |||
| #define FUNC_NAME    TEXT(__FUNCTION__) | |||
| AYourActor::log(FString sText) const | |||
| #else // FIXME - GCC? | |||
| { | |||
| #define FUNC_NAME    TEXT(__func__) | |||
| 	if (GEngine) | |||
| #endif | |||
| 	{ | |||
| 		GEngine->AddOnScreenDebugMessage(-1, 5, FColor::Blue, sText); | |||
| #define LOG_LINE UE_LOG(LogTemp, Warning, TEXT("%s, file: %s, line %d"), FUNC_NAME, *FString(__FILE__), __LINE__); | |||
| 		return true; | |||
| //#define LOG_NULL(s, p) UE_LOG(LogTemp, Warning, TEXT("pointer %s %s"),s, (p?TEXT("ok"):TEXT("null") ) ); | |||
| 	} | |||
| 	else | |||
| #define PRINT(format, ...) \ | |||
| 		return false; | |||
| { \ | |||
| 	const FString sFunc = FString::Printf(TEXT("%s"), FUNC_NAME); \ | |||
| 	const FString sText = FString::Printf(TEXT(format), ##__VA_ARGS__); \ | |||
| 	const FString sMsg = FString::Printf(TEXT("%s() : %s"), *sFunc, *sText); \ | |||
| ⚫ | |||
| } | } | ||
| #define LOG(format, ...) \ | |||
| { \ | |||
|     const FString sMsg = FString::Printf(TEXT(format), ##__VA_ARGS__); \ | |||
|     UE_LOG(LogTemp, Warning, TEXT("%s() : %s"), FUNC_NAME, *sMsg);\ | |||
| ⚫ | |||
| </pre> | </pre> | ||
Revision as of 10:44, 6 May 2016
Currently using UE4 (4.10.4)
Links
Blender
- Export Options (so that the object is not lying on the side after Export/Import):
- Forward: Y Forward
- Up: Z up
 
- Changing the object's origin to its bottom:
- Switch to Edit Mode if needed (Tab). With vertex selection on, choose the center vertex in the bottom. Press Shift+S and choose Cursor to Selected. The 3D cursor will move to the selected vertex. Deselect all and switch to Object Mode (Tab).
- In Tools choose Set Origin and then Origin to 3D Cursor.
- Make sure the object's coordinates are set to 0,0,0. Now the object should be placed properly on the XY plane.
 
C++
Variable names
If you want to use real variable names but have nice names in the UE editor too, then use meta/DisplayName
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera, Meta = (DisplayName = "First Person Camera Component") )
    UCameraComponent* m_pFirstPersonCameraComponent;
owner / client /server
The instance that spawned the class is always ROLE_Authority. If an Actor is spawned on the client, the client is the authority. -- OmaManfred
OmaManfred::
And concerning the owner stuff: When you spawn an instance of a class on the server FOR Client A, you have to set him as the owner. FActorSpawnParameters params; params.Owner = PlayerAPlayerController; SpawnActor<Class>(Class:StaticClass(),params); Then on Client B you can say IsOwner(PlayerBPlayerController), which should return false.
Logging
The following is just a copy/paste/change from the UE4 wiki and was really done from different persons, I am just using the work of different people here. Put it in a Log.h and put it into your <your_project>.h file before the #include "Engine.h".
// macros
// - LOG_LINE
// - LOG -> output log
// -- LOG("text");
// -- LOG("text %s %f %d", "text", 1.2, 5);
// - print -> screen
// -- print("text");
// -- print("text %s %f %d", "text", 1.2, 5);
#if _MSC_VER
#define FUNC_NAME    TEXT(__FUNCTION__)
#else // FIXME - GCC?
#define FUNC_NAME    TEXT(__func__)
#endif
#define LOG_LINE UE_LOG(LogTemp, Warning, TEXT("%s, file: %s, line %d"), FUNC_NAME, *FString(__FILE__), __LINE__);
//#define LOG_NULL(s, p) UE_LOG(LogTemp, Warning, TEXT("pointer %s %s"),s, (p?TEXT("ok"):TEXT("null") ) );
#define PRINT(format, ...) \
{ \
	const FString sFunc = FString::Printf(TEXT("%s"), FUNC_NAME); \
	const FString sText = FString::Printf(TEXT(format), ##__VA_ARGS__); \
	const FString sMsg = FString::Printf(TEXT("%s() : %s"), *sFunc, *sText); \
	if (GEngine) GEngine->AddOnScreenDebugMessage(-1, 5, FColor::White, sMsg); \
}
#define LOG(format, ...) \
{ \
    const FString sMsg = FString::Printf(TEXT(format), ##__VA_ARGS__); \
    UE_LOG(LogTemp, Warning, TEXT("%s() : %s"), FUNC_NAME, *sMsg);\
}
Misc
Source control
The minimum you have to put under source control:
/Config /Content /Source Project.uproject
