Ali_Akbar
(Ali_Akbar)
October 18, 2016, 1:45pm
1128
Hello,
Do you know if it’s possible to access a marker emitter local variable from c++ code ?
EDIT: hmm, this formulation might be misleading, what i mean is “can the emitter BP see a variable from my code ?” (then i could “set” the local BP variable with my code variable in the event graph)
To take a concrete example, in your adjacent cell emitter, you have defined a “distance” variable to fill empty space more or less.
I’d like to drive this variable from my code (and other variables i have created in my own marker emitter BPs).
But the marker emitters are UObjects, so they do not have any access to their ADungeon owner, or UWorld, or the engine, or GameState, or any actor i could use as a proxy.
And as they are declared as a TArray in the ADungeon, creating a class inheriting from your emitter class would be useless as far as i can say (as it wouldn’t be used by your code).
So i’m a bit stuck , the emitters BP seem to be inside an isolated bubble which i can’t enter.
I have pretty much no experience with BP so maybe i’m missing some big thing.
Any idea ?
Thanks a lot
And again, 1000 bravos for DA, a real piece of brillant work, i really hope one day we’ll see Terrain A. and City A. in UE4, you’ll have one enthusiastic customer for both of them !
Cheers
, the emitter BP can see your variables from code. You need to add a reference to your C++ actor that drives this variable and read it from there
's an example where from the BP, I’m grabbing the distance (random value between 1-6) from C++
C++ code that drives the distance variable:
AMyDungeonController.h
#pragma once
#include "AMyDungeonController.generated.h"
UCLASS(Blueprintable)
class AMyDungeonController : public AActor
{
GENERATED_BODY()
public:
UFUNCTION(BlueprintCallable, BlueprintPure, Category = MyDungeonController)
int32 GetMountainDistance();
};
AMyDungeonController.cpp
#include "DA413X.h" // pch
#include "AMyDungeonController.h"
int32 AMyDungeonController::GetMountainDistance()
{
return FMath::RandRange(1, 6);
}
Add a variable in the emitter BP that takes a references to your controller code and make it public
Grab the distance from your C++ code
Finally, set the reference of your C++ code in the marker emitter when you register it in the Dungeon actor. (The assumption is that you have it somewhere placed in the level, which you probably do)
Clicking build now randomly generates rocks that are 1-6 layers deep