So I just finished part 8 and when I add a spawn volume to my game it appears below the room and it can not move. Also I don’t see the inherited method WhereToSpawn as in the tutorial. I followed every step correctly and don’t know why this happens.
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "GameFramework/Actor.h"
#include "SpawnVolume.generated.h"
UCLASS()
class BATTERYCOLLECTOR_API ASpawnVolume : public AActor
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
ASpawnVolume();
// Called when the game starts or when spawned
virtual void BeginPlay() override;
// Called every frame
virtual void Tick( float DeltaSeconds ) override;
/** Returns the WhereToSpawn subobject */
FORCEINLINE class UBoxComponent* GetWhereToSpawn() const { return WhereToSpawn; }
/** Find a random point within the BoxComponent */
UFUNCTION(BlueprintPure, Category = "Spawning")
FVector GetRandomPointInVolume();
protected:
/** The pickup to spawn */
UPROPERTY(EditAnywhere, Category = "Spawning")
TSubclassOf<class APickup> WhatToSpawn;
FTimerHandle SpawnTimer;
/** Min spawn delay */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Spawning")
float SpawnDelayRangeLow;
/** Max spawn delay */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Spawning")
float SpawnDelayRangeHigh;
private:
/** Box component to specify where pickups should spawn */
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Spawning", meta = (AllowPrivateAccess = "true"))
class UBoxComponent* WhereToSpawn;
/** Handle spawning a new pickup */
void SpawnPickup();
/** The current spawn delay */
float SpawnDelay;
};
Hey Nik1-
Can you provide the code for your spawn volume class? Can you make sure that WhereToSpawn is set as a UPROPERTY in code so that it is visible to the editor?
Thank you for interest but I have found the solution. It seems that KismetMathLibrary does not actually load the method definitions. I had to get the code from the method RandomPointInBoundingBox and paste it where I needed it.