Fix static mesh inhabiting the incorrect position

This commit is contained in:
baz 2024-03-12 19:56:17 +00:00
parent e2e32e0092
commit 1b32434d98
1 changed files with 4 additions and 5 deletions

View File

@ -14,9 +14,8 @@ AStaticMeshPickup::AStaticMeshPickup()
void AStaticMeshPickup::BeginPlay()
{
Super::BeginPlay();
StaticMeshComponent->SetWorldLocation(this->GetActorLocation());
StartingLocation = this->GetActorLocation();
StartingLocation = StaticMeshComponent->GetRelativeLocation();
StaticMeshComponent->SetCollisionProfileName(FName("NoCollision"));
}
@ -26,10 +25,10 @@ void AStaticMeshPickup::Tick(float DeltaTime)
if (StaticMeshComponent)
{
// Rotate Weapon in desired direction
// Rotate StaticMesh in desired direction
StaticMeshComponent->AddLocalRotation((SpinRotation * RotationSpeed) * DeltaTime);
// Bob weapon up and down
// Bob StaticMesh up and down
const float Time = GetWorld()->GetRealTimeSeconds();
const float Sine = FMath::Abs(FMath::Sin(Time * MovementSpeed));
StaticMeshComponent->SetRelativeLocation(StartingLocation + ((MovementDirection * Sine) * MovementDistance));