[UE4]Root Motion

Root Motion 设置步骤: 先在 AnimSequence 的Asset Detail面板中勾选EnableRootMotion和Force Root Lock`。 然后基于该 AnimSequence 新建一个 AnimMontage。 然后再在 AnimationBluerpint 中设置Root Motion Mode为 Root Motion From Montages Only(Class Defaults 面板下,不是Class Settings)。 如果你没有使用UE4的服务器、或者使用了UE4服务器但是没有对动画启用Replication(服务端通过 NetMulticast 播放动画),设置为Root Motion from Enerything没有问题,如果使用了UE4的Replication,且这些动画文件(AnimSequence, Blendspace, AnimMontage, etc.)勾选了EnableRootMotion,那么 Root Motion 也会被同步,影响性能。所以官方文档上的建议是使用默认设置,即:Root Motion Mode设置为Root Motion From Montages Only,只对Montage的Root Motion进行Replication。 Root Motion https://docs.unrealengine.com/en-US/Engine/Animation/RootMotion

Continue reading

enum 1, define UENUM() enum Status { Stopped UMETA(DisplayName = "Stopped"), Moving UMETA(DisplayName = "Moving"), Attacking UMETA(DisplayName = "Attacking"), }; 2, using UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Status) TEnumAsByte<Status> status; struct 1, define USTRUCT(BlueprintType) struct TESTPROJ_API FMyStruct { GENERATED_USTRUCT_BODY() UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Test") int32 Test; FMyStruct() { } }; 2, using UPROPERTY(EditDefaultsOnly, BlueprintReadOnly) FMyStruct Test;

Continue reading

[UE4]Assertions

Reporting errors and halting execution. check(): like assert() in C, can be disabled by DO_CHECK 0 verify(): like check(), but the expression is still executed on DO_CHECK 0 (e.g. for variable assignments) disadvantage: halts program execution (application ends, Editor users can loose unsaved work). when to use: catch fatal errors Reporting errors and halting execution exclusively in debug builds. checkSlow(), checkfSlow(), verifySlow() (see (1)) difference to (1): they are only active in debug builds (when DO_GUARD_SLOW 1)

Continue reading

Creating Interactive Grass in Unreal Engine 4 https://www.raywenderlich.com/6314-creating-interactive-grass-in-unreal-engine-4 Creating Snow Trails in Unreal Engine 4 https://www.raywenderlich.com/5760-creating-snow-trails-in-unreal-engine-4 Dynamic Mesh Painting in Unreal Engine 4 https://www.raywenderlich.com/6817-dynamic-mesh-painting-in-unreal-engine-4 Custom Depth in Unreal Engine 4 https://www.tomlooman.com/the-many-uses-of-custom-depth-in-unreal-4/

Continue reading

Error 1 Error Log: A problem occurred configuring root project 'app'. > Could not resolve all files for configuration ':classpath'. > Could not download kotlin-reflect.jar (org.jetbrains.kotlin:kotlin-reflect:1.1.3-2) > Could not get resource 'https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-reflect/1.1.3-2/kotlin-reflect-1.1.3-2.jar'. > Could not GET 'https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-reflect/1.1.3-2/kotlin-reflect-1.1.3-2.jar'. > Software caused connection abort: recv failed > Could not download protobuf-java.jar (com.google.protobuf:protobuf-java:3.0.0) > Could not get resource 'https://jcenter.bintray.com/com/google/protobuf/protobuf-java/3.0.0/protobuf-java-3.0.0.jar'. > Could not GET 'https://jcenter.bintray.com/com/google/protobuf/protobuf-java/3.0.0/protobuf-java-3.0.0.jar'. > Software caused connection abort: recv failed Solution:

Continue reading

Keywords:运行时期间修改后处理设置, change post process settings when game is running. 运行时修改Post Process 步骤 1,使用 Camera Component 拉出 Set members in PostProcessSettings 节点。 Get reference to Camera Component and drag out “Set members in PostProcessSettings” node. 2,选中 Set members in PostProcessSettings 节点,然后再在 Detail 面板中勾选需要修改的属性。比如我想修改曝光亮度。 select “Set members in PostProcessSettings” node, then checked properties which want to modify in Detail Panel. e.g. Brightness of Exposure. 3,将 Camera 组件的 属性” Post Process Blend Weight” 设置为1,表示完全启用摄像机的 Post Process Settings。0表示完全禁用,0到1的数值表示混合过渡“全完启用”到“完全禁用”之间的渐变效果。

Continue reading

EndPlay、BeginDestroy、Destroy 的调用时机 如果要获取 Actor 销毁时的准确时间点,建议重写 Destroy() 函数,而不是EndPlay()、BeginDestroy()。 官方文档上说 EndPlay 会在执行Destroy的时候触发,但实际上并不会(至少4.20版本中测试过不会),而是当 Actor 所在场景销毁时(比如退出编辑器)才会调用。 BeginDestroy()、IsReadyForFinishDestroy()、FinishDestroy() 是在执行垃圾回收时才会触发的函数,而不是对象被 Destroy 后立即执行的函数。 官方文档 https://docs.unrealengine.com/en-us/Programming/UnrealArchitecture/Actors/ActorLifecycle

Continue reading

UProjectileMovementComponent相关 官方第一人称射击模版项目中,是在构造函数中就设置好了速度: ProjectileMovement = CreateDefaultSubobject<UProjectileMovementComponent>(TEXT("ProjectileComp")); ProjectileMovement->UpdatedComponent = CollisionComp; ProjectileMovement->InitialSpeed = 3000.f; ProjectileMovement->MaxSpeed = 3000.f; ProjectileMovement->bRotationFollowsVelocity = true; ProjectileMovement->bShouldBounce = true; 两个问题: 如何停止移动; 如何在运行时期间修改速度; 问题1解决方法: 默认情况下,Actor spawn之后,就会受到 ProjectileMovement 影响立即移动,如何在 Spawn 之后马上停止移动: ProjectileMovement->Deactivate(); 问题2解决方法: 如何在 Spawn 之后修改 Speed,两种方式: UProjectileMovementComponent->SetVelocityInLocalSpace(FVector NewVelocity); 或者 UProjectileMovementComponent->Velocity = NewVelocity; 前者速度方向是相对于 UProjectileMovementComponent本地坐标系 的相对Rotation,后者速度方向是相对于世界坐标系的绝对Rotation。 注意:当使用 UProjectileMovementComponent 后,UPrimitiveComponent::SetSimulatePhysics() 启用物理会与 ProjectileMovement 冲突。如果要使用物理,那么只能去掉 UProjectileMovementComponent ,使用 Add Impulse 来代替。 参考: Simulate Physics and Projectile Movement Component

Continue reading

UE4 的 TSharedPtr、TWeakObjectPtr 模仿自 C++11 的 shared_ptr 、 weak_ptr 。 TSharedPtr TSharedPtr 相当于对象的引用计数器。每当对 TSharedPtr 赋值一次,该 TSharedPtr 引用对象计数加一,当引用计数为0时,则该对象被自动销毁。TSharedPtr 可以防止 raw pointer 对象被垃圾回收,。 用法: TSharedPtr<TestClass> ObjPtr = MakeShareable(new TestClass()); 如果两个 TSharedPtr 相互赋值,则会导致对象永不释放,导致内存泄漏。 Uobject 不能使用 TSharedPtr 进行引用计数,非UObject才可以;如果一个非UObject的类想加入GC,那么必须继承FGCObject类。 TWeakObjectPtr TWeakObjectPtr 保持的对象不能防止被垃圾回收。若引用的对象在其他地方被销毁,则 TWeakObjectPtr 内部的指针自动将被置为NULL,TWeakObjectPtr::IsValid()会返回false。TSharedPtr 则没有这个作用。 用法: TWeakObjectPtr<MyUObject> ObjPtr = NewObject<MyUObject>(); 参考资料: UE4 TSharedPtr和UObject的垃圾回收 http://www.v5xy.com/?p=808 There’s a Huge Difference, One Will Always Crash https://answers.unrealengine.com/questions/48818/whats-the-difference-between-using-tweakobjectptr.html what is a “weak object pointer”?

Continue reading

4.19 编译错误: 2>F:\EpicGames\UE_4.19\Engine\Source\Runtime\Engine\Classes\Engine/TextureCube.h(69): error C3668: 'UTextureCube::UpdateResourceW': method with override specifier 'override' did not override any base class methods 2>F:\EpicGames\UE_4.19\Engine\Source\Runtime\Engine\Classes\Engine/CanvasRenderTarget2D.h(43): error C3668: 'UCanvasRenderTarget2D::UpdateResourceW': method with override specifier 'override' did not override any base class methods 4.18 编译错误: 2>f:\epicgames\ue_4.18\engine\source\runtime\core\public\HAL/ThreadSafeCounter64.h(67): error C2039: '_InterlockedIncrement': is not a member of 'FWindowsPlatformAtomics' 2>F:\EpicGames\UE_4.18\Engine\Source\Runtime\Core\Public\Windows/WindowsPlatformAtomics.h(14): note: see declaration of 'FWindowsPlatformAtomics' 2>f:\epicgames\ue_4.18\engine\source\runtime\core\public\HAL/ThreadSafeCounter64.h(67): error C2665: '_InterlockedIncrement': none of the 4 overloads could convert all the argument types 2>C:\Program Files (x86)\Windows Kits\8.

Continue reading

调用UFunction 执行UFuncion,使用 ProcessEvent : UFunction* Fun = Actor->FindFunction(TEXT("TestFun")); if(Fun) { Actor->ProcessEvent(Fun, Buffer); } 查询UFunction信息 获取返回值: UFunction* Fun = Actor->FindFunction(TEXT("TestFun")); if(Fun) { FFrame frame = FFrame(Actor, Fun, Buffer, NULL, Fun->Children); uint8* ReturnValueAdress = Buffer + Fun->ReturnValueOffset; int* intp = (int*)ReturnValueAdress; //hardcoded exemple for a int return Fun->Invoke(Actor, frame, intp); } 获取输出参数: if(UFunction* Fun = Actor->FindFunction(TEXT("TestFun"))) { if(uint8* Buffer = (uint8*)FMemory_Alloca(Fun->ParmsSize)) { for (TFieldIterator<UProperty> PropIt(Fun, EFieldIteratorFlags::ExcludeSuper); PropIt; ++PropIt) { UProperty* Property = *PropIt; bool isOut = Property->HasAnyPropertyFlags(CPF_OutParm); if (!

Continue reading

工程1 在油管上看到一个UE4 IK动画的demo工程示例 该示例作者的主页:https://www.patreon.com/unrealcg 演示视频:Advanced foot IK for Unreal Engine 4 - (100% Free) https://www.youtube.com/watch?v=XetC9ivIXFc demo工程下载地址(4.19): https://pan.baidu.com/s/1mlcM0cseKWpprnISVM0P5Q 工程2 该工程除了IK,还包括动画融合、物理等功能 演示视频:UE4 - Advanced Locomotion System V3 - Features https://www.youtube.com/watch?v=yTniZCOCY7o 下载地址:Unreal商城,60刀 Advanced Locomotion System V3 https://www.unrealengine.com/marketplace/advanced-locomotion-system-v1 认识自己的无知是认识世界的最可靠的方法。---米歇尔·蒙田《随笔集》

Continue reading

参考自:Master pose vs copy pose vs mesh merge in UE4 https://iluvanimation.blogspot.tw/2017/04/master-pose-vs-copy-pose-vs-mesh-merge.html Since I get this question so often, I’m just writing quick summary for each. When you have different parts of bodies, and you want to allow players to pick which part they want, we have multiple choices, and people are wondering what are the main differences. Say you have head, upper body, lower body, and how do you allow them to pick and what are the differences?

Continue reading

keyworks:Animation Blueprint Inherit、Animation Blueprint Reuse、蓝图继承、蓝图重用、蓝图复用 三种方式可以重用动画蓝图逻辑: Blueprint Inherit(蓝图继承) Sub Animation Blueprint Instances Post Process Animation Blueprints Animation Blueprint Inherit(动画蓝图继承) 角色蓝图继承和动画蓝图继承有部分相似,这里先说下角色蓝图继承 右键角色蓝图 -》 Create Child Blueprint Class 这样创建出来的子蓝图,其构造函数中会自动生成一个执行父级蓝图构造函数的节点 其他的Event事件中,如果也需要调用父级蓝图的函数,可以右键对应节点 -》 Add call to parent function 动画蓝图也可以使用上述角色蓝图继承的方式。 但直接右键生成子蓝图的方式创建出来的动画蓝图,无法选择其他骨骼,只能保持和父级动画蓝图的骨骼一样 如果要创建一个与父级动画蓝图骨骼不同的子动画蓝图,可以先新建一个普通的动画蓝图 然后选择需要继承的父级动画蓝图,以及子动画蓝图的骨骼 这样生成出来的子动画蓝图,其Event Graph中,会自动生成一个执行调用父级蓝图的节点:Parent: Blueprint Update Animation Sub Animation Blueprint Instance Using Sub Anim Instances

Continue reading

keywords:UE4 Animation、Set Master Pose Component、customizable character、动画蓝图、换装 美术资源制作 每个身体部件(帽子、鞋子等)蒙皮时需要使用同一套骨骼(all pieces need to be skinned to the same skeleton) 每个身体部件导出时,该部件的关节与根关节之间的所有关节都需要选中导出。例如:假设盆骨为根关节(root joint),现在要导出手臂,那么手臂、肩膀、脊椎、盆骨的关节都需要选中导出。 角色蓝图中设置Master Pose 身体各个部件导入UE4之后,打开角色蓝图,为每个部件Add一个Skeleton Mesh Component,并将其Skeleton Mesh属性设置为对应的资源文件。 最后再在角色蓝图的Construction Script中Set Master Pose Component 这样,角色在播放动画时,每个部件就会跟随角色一起播放,而不会固定不动。 参考自:How to Setup “Master Pose Component” https://answers.unrealengine.com/questions/228601/how-to-setup-master-pose-component.html C++接口 Set Master Pose Component蓝图节点对应的C++ API: Child->SetMaseterPoseComponent(Body); 有一个传说,说的是有那么一只鸟儿,它一生只唱一次,那歌声比世上所有一切生灵的歌声都更加优美动听。---《荆棘鸟》

Continue reading

Author's picture

Neil Wang

久长唯有品格

To Be Marvelous

Yichang·Hubei