Skip to content

Instantly share code, notes, and snippets.

@zerescas
Last active July 6, 2023 12:17
Show Gist options
  • Save zerescas/26744490292c7dd7034fb423676a7ed7 to your computer and use it in GitHub Desktop.
Save zerescas/26744490292c7dd7034fb423676a7ed7 to your computer and use it in GitHub Desktop.
Create UStaticMeshComponent variable from C++ | Setup it in Blueprint | Rotate UStaticMeshComponent from C++
// Fill out your copyright notice in the Description page of Project Settings.
#include "AnotherCamera/Public/RotatingActor.h"
// Sets default values
ARotatingActor::ARotatingActor()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
}
// Called when the game starts or when spawned
void ARotatingActor::BeginPlay()
{
Super::BeginPlay();
}
// Called every frame
void ARotatingActor::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
if(RotatingObject)
{
RotatingObject->AddRelativeRotation(AddRelativeRotation);
}
}
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "RotatingActor.generated.h"
UCLASS()
class ANOTHERCAMERA_API ARotatingActor : public AActor
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
ARotatingActor();
UPROPERTY(BlueprintReadWrite, EditAnywhere)
UStaticMeshComponent* RotatingObject;
UPROPERTY(BlueprintReadWrite, EditAnywhere)
FRotator AddRelativeRotation;
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
public:
// Called every frame
virtual void Tick(float DeltaTime) override;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment