1205
(1205)
February 5, 2016, 2:59am
1
//Class A
UCLASS()
class AFrameWorkCameraManager : public APlayerCameraManager
{
public:
AActor* m_pMyActor;
public:
virtaul void Tick(float _time) override;
}
void AFrameWorkCameraManager ::Tick(float _time)
{
if(m_pMyActor)
{
//stuff somthing
}
}
and here is class B’s (.h, .cpp)
//class B
class B : public AActor
{
public:
virtual void BeginPlay() override;
}
void B::BeginPlay()
{
UClass* p1 = AFrameWorkCameraManager ::staticClass();
AFrameWorkCameraManager* p2 = ((AFrameWorkCameraManager*)p1);
if(p2)
{
p2->m_pMyActor= this;
}
}
I thought beginplay Function is called before Tick Function
So, class AFrameWorkCameraManager’s Tick
if(m_pMyActor) will be not “NULL” i thought
but, that value was NULL;
what’s going on?
what is my mistake?
condition : class B cant have class AFrameWorkCameraManager as member value.
You code looks really wierd, how do you set pOtherActor? Also what the heck is this mostrosity
UClass* p1 = AFrameWorkCameraManager ::staticClass();
AFrameWorkCameraManager* p2 = ((AFrameWorkCameraManager*)p1);
If you want to spawn actor use ()->SpawnActor(p1);
1205
(1205)
February 5, 2016, 3:16am
3
wow, thanks to .
your answer was so nice to me, helpful!
anyway…
I wirte here all i intended
first step is here
many Camera Actors is set in MyLevel
Second step.
class AFrameWorkCameraManager has TArray (use add function)
it will be assigned many Camera Actor in Level ( at Camera Actor’s C++ Script BeginPlay Function)
but!! one problem appeared
I can’t access to AFrameWorkCameraManager in Camera Actor class’s function
so, I find staticClass() Function as Problem Answer
like upper code
upper code is sample, but principle is same
last step is
I choice One Actor Camera in Array (AFrameWorkCameraManager)
and this Actor Camera will be Target (use SetViewTarget)
1205
(1205)
February 5, 2016, 3:18am
4
i have crash in second step
1205
(1205)
February 5, 2016, 3:20am
5
pOtherActor Set code is there
if(p2)
{
p2->pOtherActor = this;
}
Obviuesly you have problem in step 2, and it’s not because something is null but it’s because invalid cast (thats why i called monstrocity :p)
UClass* p1 = AFrameWorkCameraManager ::staticClass();
AFrameWorkCameraManager* p2 = ((AFrameWorkCameraManager*)p1);
StaticClass() return UClass* which is class identifier (which you can use to spawn for example), it is not a object of a class, so you can’t cast it to object pointer. All this can be replaced withone line
AFrameWorkCameraManager* p2 = Cast<AFrameWorkCameraManager>(GEngine->GetFirstLocalPlayerController()->GetCameraManager());
Also didn’t i told you to use ViewTarget insted on other quastion? I told you it a lot easier
1205
(1205)
February 5, 2016, 3:36am
7
yep, i will use ViewTarget like other question(thanks you veryful).
but before use that function.
i have to have some Camera Actor in CameraManager(TArray)
this Question is about that flow.
1205
(1205)
February 5, 2016, 3:37am
8
i try to this code
AFrameWorkCameraManager* p2 =
Cast(GEngine->
GetFirstLocalPlayerController()->GetCameraManager());
but can not find "GetCameraManager"Function
1205
(1205)
February 5, 2016, 3:39am
9
ah i find “PlayerCameraManager”
1205
(1205)
February 5, 2016, 3:40am
10
God bless you.
It work! also ViewTarget
1205
(1205)
February 5, 2016, 8:19am
11
are you there…?
so sorry say to that…
after SetViewTarget PlayerController by
GEngine-> GetFirstLocalPlayerController(()) ->SetViewTarget(CamActor),
I cant controll My Actor
any key input stop like w,s,a,d
I think SetViewTarget just View Target, not character possess
so, Character still origin position
Thats wierd, i dont see any possession, or else your code use view target for controls.
Try setting bAutoManageActiveCameraTarget to false in player controller, it will make setting view target 100% manual, that mean if you possess pawn it wont set that pawn as a view target.
Also make sure you use GetPawn() to interact with pawn in controller