碰撞,处理碰撞,发射 Learn Unreal Engine (with C++)
生活随笔
收集整理的這篇文章主要介紹了
碰撞,处理碰撞,发射 Learn Unreal Engine (with C++)
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
本文使用打磚塊游戲舉例
碰撞,處理碰撞
碰撞就相當于一個Actor進入另一個Box中,用這個思路就可以處理碰撞了
OnComponentBeginOverlap
當某些內容開始重疊此組件時調用的事件,例如玩家進入觸發器。
**委托 事件 **1
AddDynamic( UserObject, FuncName )
用于在動態組播委托上調用AddDynamic()的輔助宏。自動生成函數命名字符串。
當碰撞時
UFUNCTION()void OnOverlapBegin(class UPrimitiveComponent* OverlappedComp, class AActor* OtherActor,class UPrimitiveComponent* OtherComp, int32 OtherBodyIndexType, bool bFromSweep,const FHitResult& SweepResult); void ABrick::BeginPlay() {Super::BeginPlay();Box_Collision->OnComponentBeginOverlap.AddDynamic(this, &ABrick::OnOverlapBegin); } /** 當某對象進入球體組件時調用 */ UFUNCTION() void OnOverlapBegin(class UPrimitiveComponent* OverlappedComp, class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult);/** 當某對象離開球體組件時調用 */ UFUNCTION() void OnOverlapEnd(class UPrimitiveComponent* OverlappedComp, class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex);發射
GetBall()->AddForce(FVector(0.0f, 0.0f, 1000.0f), FName(), true); SM_Ball->AddImpulse(FVector(140.0f, 0.0f, 130.0f), FName(), true);UPrimitiveComponent::AddImpulse2
給一個剛體增加一個沖量。好一時瞬間爆發
UPrimitiveComponent::AddForce
對單個剛體施加一個力
僅使用C++ | 虛幻引擎文檔 (unrealengine.com) ??
UPrimitiveComponent::AddImpulse | Unreal Engine Documentation ??
總結
以上是生活随笔為你收集整理的碰撞,处理碰撞,发射 Learn Unreal Engine (with C++)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: STL常用算法的使用及举例
- 下一篇: s3c2440移植MQTT