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