Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Fill out your copyright notice in the Description page of Project Settings.
- #include "HowTo_Components.h"
- #include "OrbitMovementComponent.h"
- #include "MySceneComponent.h"
- // Sets default values for this component's properties
- UMySceneComponent::UMySceneComponent()
- {
- // 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;
- UStaticMeshComponent* SphereVisual = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("VVisualRepresentation"));
- SphereVisual->SetupAttachment(this);
- static ConstructorHelpers::FObjectFinder<UStaticMesh> SphereVisualAsset(TEXT("/Game/StarterContent/Shapes/Shape_Sphere.Shape_Sphere"));
- if (SphereVisualAsset.Succeeded())
- {
- SphereVisual->SetStaticMesh(SphereVisualAsset.Object);
- SphereVisual->SetRelativeLocation(FVector(0.0f, 0.0f, 0.0f));
- SphereVisual->SetWorldScale3D(FVector(0.4f));
- SphereVisual->RegisterComponent();
- SphereVisual->RegisterAllComponentTickFunctions(true);
- }
- // ...
- }
- // Called when the game starts
- void UMySceneComponent::BeginPlay()
- {
- Super::BeginPlay();
- m_time = 0;
- }
- // Called every frame
- void UMySceneComponent::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
- {
- Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
- m_time += DeltaTime;
- this->SetRelativeLocation(FVector(sin(m_time), cos(m_time), 100) * 140);
- // ...
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement