Hi there, thanks for looking at my question!
I have been learning C++ for a month or so to try get a handle on it for general use but also to have a better understanding when I started learning Unreal.
I am in the first C++ unreal tutorial where toy make a floating Actor that bobs up and down and I understood it, but at the end it asks you to add 2 more axis of movement at different rates.
I thought I had the answer but I see now that I was just increasing the value of Sin by multiplying the delta time by a different amount for each direction, which increases the length the object moves, but it takes the same time in all directions, resulting in a vector motion. What I want is for it to take different amounts of time to complete a full cycle in each axis so that it looks like it is bobbing about in all directions.
// Called every frame
void AFloatingActor::Tick( float DeltaTime )
{
Super::Tick( DeltaTime );
FVector NewLocation = GetActorLocation();
float DeltaHeight = (FMath::Sin(RunningTime + DeltaTime) - FMath::Sin(RunningTime));
NewLocation.Z += DeltaHeight * 20.0f;
float DeltaDepth = (FMath::Sin(RunningTime + DeltaTime) - FMath::Sin(RunningTime));
NewLocation.X += DeltaHeight * 10.0f;
float DeltaWidth = (FMath::Sin(RunningTime + DeltaTime) - FMath::Sin(RunningTime));
NewLocation.Y += DeltaHeight * 10.0f;
RunningTime += DeltaTime;
SetActorLocation(NewLocation);
So for example I want it to move up and down once fully every 3 seconds, back to front every 2.5 seconds and side to side every 4 seconds.
I hope that is sort of clear. Can anyone help?