Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


We're also offering banner ads on our site from just $5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


[Unrealscript] Why isn't PostBeginPlay() appearing?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
No replies to this topic

#1 Sammieo   Members   -  Reputation: 147

Like
0Likes
Like

Posted 04 March 2013 - 07:59 AM

EDIT: As a heads-up, this doesn't seem to be an issue anymore, though I'm genuinely not sure why. Ah well, can't complain!

I'm working with unrealscript now, and I have a nice little controller. The PostBeginPlay() function, however, doesn't seem to be as reliable as I want it to be; I'm using it to set up a few things, but I've noticed through use of log messages that PostBeginPlay() doesn't seem to appear when I want it to.

Just take a look at my code. Blue lines are log messages that appear in the launch log file: red lines are ones that don't.

 

 

class MagpieController extends AIController;

var Pawn CrowPawn;

var Actor CrowActor;

var float AttackDistance;
var float ChaseDistance;
var float MovementSpeed;

simulated function PostBeginPlay()
{
  `log("A magpie CONTROLLER has appeared on the map!"); //appears
  if (CrowPawn == none)
  {
    `log("Targeting the crow now!"); //appears, but because the player appears after the magpie does the bottom function call doesn't work
    TargetCrow();
  }
  `log("Just making sure that, yes, the magpie controller is still here!"); //appears
  GoToState('Searching');
}

function Tick(float DeltaTime)
{
  `log("The magpie's just sitting here, twitchin' its talons!"); //doesn't appear because the GoToState('Searching') part works fine!
}

auto state Searching
{
  simulated function PostBeginPlay()
  {
    `log("The magpie is now SEARCHING!"); //never appears
    if (CrowPawn == none)
    {
      TargetCrow();
    }
  }
  function Tick (float DeltaTime)
  {
    `log("I'm still looking for crows!"); //appears
    
    if (CrowPawn == none)
    {
      TargetCrow();
    }
    if (VSize(Location - CrowPawn.Location) < ChaseDistance)
    {
      `log("Right, the magpie now sees the player!"); //appears

      GoToState('ChasingPlayer');
    }
  }
}

state ChasingPlayer
{
  simulated function PostBeginPlay()
  {
    `log("I'm chasing that filthy crow!"); //never appears
  }

  function Tick(float DeltaTime)
  {
    local vector NewLocation;

    `log("I'm still chasing that filthy crow!"); //appears

    if(CrowPawn == none)
    {
        TargetCrow();
    }

    while (CrowPawn != none && VSize(NewLocation - CrowPawn.Location) < AttackDistance)
    {
      `log(Location);
        NewLocation = Location;
        NewLocation += normal(CrowPawn.Location - Location) * MovementSpeed * DeltaTime;
        SetLocation(NewLocation);
    }
  }
}

function TargetCrow()
{
  local CrowPlayerController PC;
  foreach LocalPlayerControllers(class'CrowPlayerController', PC)
  {
    if (PC.Pawn != none)
    {
        CrowPawn = PC.Pawn;
        `log("My enemy is:" @ CrowPawn);
    }
  }
}


Can anyone please offer an explanation for this?


Edited by Sammieo, 05 March 2013 - 05:06 AM.


Sponsor:



Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS