http://blog.csdn.net/or_7r_ccl/article/details/54564962

直接在sequence or montage中new个Event

然后在graph中接收。 


2、简单的通知(c++)

首先,animation bp必须是继承自定义的AnimInstance 

然后新建两个通知AnimNotify_Begin和AnimNotify_End 

方法的命名规则必须是AnimNotify_XXX,因为引擎里的代码就是这样匹配的 

完整代码 

MyAnimInstance.h

#pragma once

#include "Animation/AnimInstance.h"
#include "MyAnimInstance.generated.h" /**
*
*/
UCLASS()
class MYSLATE_API UMyAnimInstance : public UAnimInstance
{
GENERATED_BODY() public:
UMyAnimInstance(); UFUNCTION(BlueprintCallable, Category = "MyAnim")
bool IsMoving(); UFUNCTION(BlueprintCallable, Category = "MyAnim")
ACharacter* GetOwnerChar(); UFUNCTION(BlueprintCallable, Category = "MyAnim")
void AnimNotify_Begin(UAnimNotify* Notify);
UFUNCTION(BlueprintCallable, Category = "MyAnim")
void AnimNotify_End(UAnimNotify* Notify);
private:
ACharacter* mOwnerChar;
};
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29

MyAnimInstance.cpp

#include "MySlate.h"
#include "MyAnimInstance.h"
#include "Engine.h"
#include "MyChar.h" UMyAnimInstance::UMyAnimInstance()
{
mOwnerChar = nullptr;
} bool UMyAnimInstance::IsMoving()
{
ACharacter* character = GetOwnerChar();
if (!character)
return false; float wallSpeed = FVector::DotProduct(character->GetVelocity(), character->GetActorRotation().Vector());
return wallSpeed > 0.f ? true : false;
} ACharacter* UMyAnimInstance::GetOwnerChar()
{
if (!mOwnerChar)
{
APawn* owner = TryGetPawnOwner();
mOwnerChar = owner ? Cast<ACharacter>(owner) : nullptr;
}
return mOwnerChar;
} void UMyAnimInstance::AnimNotify_Begin(UAnimNotify * Notify)
{
AMyChar* mychar = Cast<AMyChar>(GetOwnerChar());
if (mychar)
{
FString str = FString::Printf(TEXT("--- AnimNotify_Begin - %d"), mychar->mHealth);
GEngine->AddOnScreenDebugMessage(0, 5.0f, FColor::Green, str);
}
} void UMyAnimInstance::AnimNotify_End(UAnimNotify * Notify)
{
FString str = FString::Printf(TEXT("--- AnimNotify_End"));
GEngine->AddOnScreenDebugMessage(0, 5.0f, FColor::Yellow, str);
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45

蓝图中直接new一个notify就ok了,逻辑都在c++中做。

当然,你可以new个bp继承MyAnimInstance,然后动画蓝图再继承这个bp,这样扩展性好了。 


3、单独起个AnimNotify类(blueprint,c++自己去转换)

可以重写两个方法,和其一些变量 

然后添加到animation sequence or montage中 


4、(最灵活)单独起个AnimNotifyState类(blueprint,c++自己去转换)

可以重写4个方法 

然后添加到animation sequence or montage中,可以控制通知长度,也就是tick 


其实看下源码就可以知道,里面这些东西是怎么调用的

ue4 c++ anim notify的更多相关文章

  1. 张瀚荣:如何用UE4制作3D动作游戏

    转自:http://www.gamelook.com.cn/2015/06/218267 GameLook报道/ 6月5日,2015年第三期GameLook开放日‧虚幻引擎专场活动在上海正式举行,此次 ...

  2. ue4粒子实现流血效果

    ---恢复内容开始--- 动作/射击游戏中,击中角色时常常伴随着血花效果,增强打击感的同时,也方便了玩家对命中与否的判断. 血液效果分两块,首先是受伤部位在受击瞬间产生血雾粒子,然后在身体.地面.墙面 ...

  3. Modeling -> Mixamo auto rigging -> UE4 retargeting

    In general, there are 3 ways we can work with the Blender-UE4 pipeline:   1 Model character Export m ...

  4. UE4高级运动系统(Advanced Locomotion System V3)插件分析

    Advanced Locomotion System V3是虚幻商城的一款第三方插件.它相比UE4的基础走跑跳表现,实现了更多动作游戏里常用的运动特性,虽然价格定价不菲,依然备受关注.笔者试用了这款插 ...

  5. Unreal Engine 4 系列教程 Part 7:音频教程

    .katex { display: block; text-align: center; white-space: nowrap; } .katex-display > .katex > ...

  6. UE4开发神秘海域类游戏原型 初阶(二):动画资源的整合

    前一篇已经确定神海类游戏原型的目标,首先要做的就是3C's(Character, Controls, Camera)的开发.   UE4的3C's的程序部分开发主要也就是基于他的GamePlay Fr ...

  7. 游戏开发之UE4添加角色到场景中

    接着上次继续学习,现在我们已经有了一个场景并且运行了,我们需要添加一个角色到场景中.要这样做,我们必须从UE4的GameFramework类继承它. 一. 创建一个从Character类继承的类 从基 ...

  8. ue4音效、动画结合实例

    在游戏中,许多音效需要在动画恰当的时机出现,例如行走.奔跑,就需要恰好在足部落地瞬间播放. 而AnimNotify就能非常方便地处理此类问题. AnimNotify,顾名思义就是动画通知,能在特定的动 ...

  9. UE4的委托

    UE中委托的使用很广泛,许多Event的触发都有对应的虚函数和委托,虚函数不用讲,只能在派生类中使用,而委托可以在别的类或者蓝图中使用,就应用范围而言,委托的使用更灵活.以AActor的 /** * ...

随机推荐

  1. Ceph集群rbd-mirror A、B区域备份实施方案

    Ceph集群rbd-mirror A.B区域备份实施方案 备注:首先准备两个集群, 并确认其状态,集群的准备过程在这就不做陈述 1.查看集群状态 A区域 [root@ceph2111 ceph]# c ...

  2. mini2440 u-boot禁止蜂鸣器

    mini2440的u-boot版本启动之后马上就会开启蜂鸣器,在办公环境下有可能会影响同事的工作,所以我考虑将其禁止掉. 我使用的mini2440使用的光盘是2013年10月的版本,我在该光盘下的u- ...

  3. win10安装tomcat7

    下载Tomcat 安装tomcat tomcat7是绿色软件,解压后即可使用,请大家先将tomcat解压到合适的位置(建议整个路径都是英文路径),下载 apache-tomcat-7.0.79-win ...

  4. matlab保存txt文件

    save roadsurfacepointcloud.xyz -ascii roaddata2 %保存路面点云文件 roaddata2是变量.

  5. python根据圆的参数方程求圆上任意一点的坐标

    from math import cos, sin,pi x0,y0=0,0 r=4.0 angle=-25 x1 = x0 + r * cos(angle * pi / 180) y1 = y0 + ...

  6. Android 7.1 GUI系统-窗口管理WMS-Surface管理(四)

    Surface的管理 Surface是窗口能真正显示到物理屏幕上的基础,由surfaceflinger管理,可以通过WindowStateAnimator.java中的变量mDrawState来查看每 ...

  7. BZOJ 3043 IncDec Sequence:反向差分

    题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=3043 题意: 给定一个长度为n的数列a[i],每次可以选择一个区间[l,r],使这个区间内 ...

  8. 网站桌面端和手机端不同url的设置

    你的网站在搜索引擎中表现怎样很大程度上依赖于你的你的网站对于不同设备上的设计. 下面介绍了怎样基于URL构造来优化你的网站对于搜索引擎的支持. 决定你网页的URL构造 Determine the UR ...

  9. listen 60

    Barbie Exposure May Limit Girls' Career Imagination The ubiquitous Barbie doll: she's been everythin ...

  10. 机器学习 scikit-learn 图谱

    scikit-learn 是机器学习领域非常热门的一个开源库,基于Python 语言写成.可以免费使用. 网址: http://scikit-learn.org/stable/index.html 上 ...