본문 바로가기

Unreal Engine4 or 5/코드11

UE4 Actor의 이동 123456789 void ARollingBall::MoveBall(){ //속도는 델타타임을 곱하여 runtime과 동기화 시키고 float speed = MoveSpeedForDeltaTime * MoveDeltaTime; //현재 위치 + 방향 * 속도 를 새로운 위치로 넣어준다. FVector newLocation = GetTransform().GetLocation() + (CurrentGoalDirection * speed); RootComponent->SetWorldLocation(newLocation);}Colored by Color Scriptercs 2016. 4. 21.
UE4 lerp를 이용한 자연스러운 회전과 angle 구하기 Step 1. Angle값 구하기. 123456789101112131415161718192021222324252627282930313233 FVector Dest = FVector(GoalPosition.X, GoalPosition.Y, 0.0f); FVector Start = FVector(GetTransform().GetLocation().X, GetTransform().GetLocation().Y, 0.0f); FVector dir = Dest - Start; GoalDirection = dir.SafeNormal(); //노말라이징한 두개의 백터를 dot한다. //여기서 축을 Z축으로 하기 위해 두백터의 Z값을 0.0f로 넣어 주었다. float dot = FVector::DotProduct(FV.. 2016. 4. 20.
현재 레벨에서의 컴퍼넌트 찾는 방법. FindObject 12345678910111213141516171819202122232425 //현재 레벨의 모든 Actor을 받아온다. TTransArray actors =GetWorld()->GetCurrentLevel()->Actors; //그중 모든 Boxcomponent만 받아온다. TArray boxComps; for (int i = 0; i FindComponentByClass()) { boxComps.Add(actors[i]->FindComponentByClass()); } } // 모든 컴퍼넌트 중 해당 tag를 가진 컴퍼넌트 리턴. for (int i = 0; i ComponentTags[j].IsEqual("StageFloorBoundBox")) { //실행 GEngine->AddOnScreenDebu.. 2016. 4. 20.