title: Object Pointer Crash in UE4 for State Machine Behaviour
body: <p>Im trying to make a finite state machine behavior and i cant seem to wrap my head around UE4s c++
  This is where I am initializing my states and setting it to the SMB</p>
  <pre><code>ATryEM::ATryEM()
  {
  
      PrimaryActorTick.bCanEverTick = true;
      MyStateMachineBehaviour = NewObject&lt;UMyStateMachineBehaviour&gt;();
      testState = NewObject&lt;UMyState&gt;();
      otherState = NewObject&lt;UMyState&gt;();
  
      if(ensure(testState))
      MyStateMachineBehaviour-&gt;Init(testState);
      
  }
  
  // Called when the game starts or when spawned
  void ATryEM::BeginPlay()
  {
      Super::BeginPlay();
      ChangeState();
  }
  
  void ATryEM::ChangeState()
  {
      if (ensure(otherState))
          MyStateMachineBehaviour-&gt;ChangeState(otherState);
  }
  </code></pre>
  <p>This is how my SMB looks like</p>
  <pre><code>
  #include &quot;MyStateMachineBehaviour.h&quot;
  
  UMyStateMachineBehaviour::UMyStateMachineBehaviour()
  {
      CurrentState = nullptr;
  }
  
  void UMyStateMachineBehaviour::Init(UMyState* initState)
  {
      if(initState)
      {
          CurrentState = initState;
          CurrentState-&gt;Enter_State();
      }
  }
  
  void UMyStateMachineBehaviour::ChangeState(UMyState* newState)
  {
      CurrentState-&gt;Exit_State();
      if (newState)
      {
          CurrentState = newState;
          CurrentState-&gt;Enter_State();
      }
  }
  
  void UMyStateMachineBehaviour::UpdateState()
  {
      if(CurrentState)
      CurrentState-&gt;Exit_State();
  }
  </code></pre>
  <p>and the states just have a debug statement.</p>