How to: translations and logging

I created a scene component and put it on a primitive sphere.
I am trying to move the sphere in the TickComponent() method.

this->ellapsed_time += DeltaTime;
this->SetRelativeLocation(FVector(1000 * sin(this->ellapsed_time * 1000), 0, 0));

This does nothing.
I try and do logging to make sure I am at all getting calls to TickComponent.

UE_LOG(LogTemp, Warning, TEXT("Hello"));

I realize I have no console to see the logging.
I find out I have to bind a key to open the console. I bind that key to § (right under my esc).
Nothing happens when I press it.

So: How do I programmatically translate something? And how do I get my console to show? and how do I log to that console?

You need a static mesh component to attach to your uscene component.
This code you posted is short, like give people to see what you have in your constructor.

I see also that you also want to set the relative location when you don’t have transforms.
Maybe Actor Location is better, move the whole actor, relative positions are on individual components to offset from the actor’s root component.

Use the actor location function.


// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "Components/SceneComponent.h"
#include "TestMove.generated.h"

UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
class TESTINGG_API UTestMove : public USceneComponent

	float ellapsed_time = 0;

	// Sets default values for this component's properties

	// Called when the game starts
	virtual void BeginPlay() override;

	// Called every frame
	virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;


// Fill out your copyright notice in the Description page of Project Settings.

#include "TestMove.h"

// Sets default values for this component's properties
	// Set this component to be initialized when the game starts, and to be ticked every frame.  You can turn these features
	// off to improve performance if you don't need them.
	PrimaryComponentTick.bCanEverTick = true;

	// ...

// Called when the game starts
void UTestMove::BeginPlay()

	this->ellapsed_time = 0;


// Called every frame
void UTestMove::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
	Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
	this->ellapsed_time += DeltaTime;

	FTransform tf = this->GetRelativeTransform();
	tf.TransformPosition(FVector(10000, 0, 0));

	UE_LOG(LogTemp, Warning, TEXT("Hello"));


I seem to not be able to find any function called SetActorLocation

You don’t have anything in your constructor.
Tutorial on how to set static mesh in constructor and attach it to root component.
Unreal Engine C++ Tutorial : Actors, Components & Meshes - YouTube

Then move the actor, with SetActorLocation, if you want it to actually move as in not teleport directly there then use deltatime, well anyway you have to first learn to sort of teleport it there and then after you get the hang of it you can make it slide there by using some function or delta time.

AActor::SetActorLocation | Unreal Engine Documentation

Youractor>SetActorLocation(FVector(blah blah blah.
Don’t forget to get location of the actor first tho.
You need to know the location of your actor on the world location first.

Just do these things first, don’t rush into moving things where things slide from one place to another, as you see them move across the screen. Try to understand the mechanicas first, and you will learn fast that way. After you do, you will slide things how ever you want with ease.

You can also slide things with SetActorLocation, like see it move across the screen.

Here is like a basic sintax.
YourLocation = GetActorLocation();
YourActor’s"AName" go’s here->SetActorLocation(YourLocation + FVector(What ever you want here));

YourLocation is a var type of what you want, Float, FVector and so on, like wise declare it first in the header or directly in the CPP if you don’t want to set UPROPERTY and don’t need it.

The solution was to:


And remember to also compile the c++ code, not just save it.

Yeah but you are moving the relative location of a component that you have attached to your actor, not the actor, so your actor remains there but it’s component just moved elsewhere.

You are going to get distortions on locations because you need to transform the world location to relative location when you are using relative location, when you have many components on an actor the relative location between them will not render corectly and you are going to get distorted locations because you have not transformed to relative local space to get the location offsets between the objects. Then you need to transform to world, to get a sync with relative local space so there is a sync between the components.

SetActorLocation moves on world space directly the main component with all the components it has. Main component is the root component that all the components are attached to.

SetRelativeLocation is just setting some component location that an actor has, not the actor it’s self, the actor remains there, and you are just moving it’s mesh component elsewhere, when you do this with many components, if you don’t transform corectly the items will have wrong offsets.

The owner of my TestMove component is the root actor I am trying to move. I understand what you mean by moving the sub-actor (The component itself) does not move the actor but rather just changes the relation between the root actor and the component. But here as I showed I now do GetOwner().

So as long as you’re not referencing float inaccuracies at large values I am not sure what you are saying with distortions.


Component placed on ‘Tractor’

Yeah it’s why you use “this” meaning this actor attached to the constructor.

But this is only when you don’t have defined names in the constructor, a definition of everything.
So it’s better to just create the static mesh with everything done in C++ inside a constructor, and then you have all the names difined , Ucomponent, StaticMesh component, RootComponent, Actor’s Name.

->SetActorLocation moves the actor it’s self on world map coordinates and all it’s components.

From what I know relative location is for components of an actor that are attached to the actor so you can move them independent from the actor’s main root component, is relative location, local space of components and difrences between them and root component.

But this is only when you don’t have defined names in the constructor, a definition of everything.

I would argue it’s better to not define everything definitively in the constructor as that would constrain the usefulness of the component to this one use-case only whereas the way it is now is more general, but I could be wrong.

Probably you’re right in that it’s a performance cost to ask for the owner with a function every tick. That would be a smart thing to save in a class variable I agree.

From what I know relative location is for components of an actor that are attached to the actor

I understand what you’re saying. But the way it is now it works the same way in all cases I can imagine, but with the added benefit that if I add this actor to another moving actor it would change to it’s reference frame. no?

Anyway thank you for your answers!

If you add now to another actor, it will have the position of the actor you are adding + the relative position of this actor you were talking about. You are going to get an offset between actors, because now this actor has a relative position to the actor you attached it to, and then you think this actor you set will appear somewhere but it will not, and it will appear relative to the possition of the other actor, so it’s not the coords you gave it to see it on the world map but the relative position to the other actor.

So maybe this is what you want then yes, SetActorRelativePoistion.