使用UE:Ver.5.0.3
ターザンロープを2本繋げた遊具を作成。
Physics Constraintを使用しただけで、処理はほとんど書いていません。
👇公式の解説動画
Blueprint
BP_Swing
ブランコのBlueprint。プラグインなど使用していない。
Physics Constraintの練習として作成。
Viewport
PhysicsConstraintの座標の向きだけ気をつける。
SceneComponentはCableのEnd位置を決めるのに使っている。


Construction Script
CableのEnd位置をSceneにするだけ。

Event Graph
CableのEnd位置をSceneにするだけ。

BP_RotationalMotion
キャラクターに回転運動させる何か。
作った関数をキャラクターに使用するために作成。
👇自作したPluginを使用しています。
KishiroLibrary
Viewport

Event Graph
Get Force for Rotational Motionが自作の関数。
回転運動の軌道から外れる速度に対して、それを妨げる力を出力する関数。
Awayがtrueだと、外側に外れる速度に対して力を出力。
Nearがtrueだと、内側に外れる速度に対して力を出力。
Intensityには質量を入れておけば、それっぽい動きになるように少しだけ調整してある。

学んだこと
Field of View
視野、視界の広さ
右クリック+C:ズームイン(低FOV)
右クリック+Z:ズームアウト(高FOV)
右クリックを離すと元に戻る。

Aの部分にベクトルを入れてGetSafeNormalを使う。Toleranceの部分には0.0001が入っているのがDefault。
FVector UKismetMathLibrary::Normal(FVector A, float Tolerance)
{
return A.GetSafeNormal(Tolerance);
}
Simulate Physicsが効いた物体はマルチプレイにおいて動きがずれる。
だが、今回のブランコのように動きが小さければ許せる気がする。
前回のシーソーはPhysics Constraintで作ると動きのブレが激しすぎた。
Simulate Physicsが効いた物体が対象のものと、Character Movement Componentが対象のものがある。
キャラクターに対してSetLocationをするとClientからの見た目がおかしくなるが、AddForceでは問題なく移動できるのが良かった。Replicate Movementが正常に効いている。
Add Forceはstaticな関数の中では使えなかった。
定義するときに前にvirtualってついてる関数。最後にoverrideもついてる。
例:BeginPlayとTick
protected:
// Called when the game starts
virtual void BeginPlay() override;
public:
// Called every frame
virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
この関数は上書き(override)できるらしい。
意味が分かっていなかったので助かった。

Twitterしてます
ブログの更新をお知らせ
コメント