Home Unreal Engine

Pawn visible only when dead ?

Hi everyone
I have a very anoying problem, I have my custom game, my custom pawn. When I right click within the editor and choose Play from Here, then It works perfectly and I got my character displayed on screen.
But when I launch the game with the editor window ( like launching the game really ) my pawn is not visible, and the only way to get him visible is to die...
This is my pawn and controller scripts,

Pawn :
class GravityGamePawn extends UTPawn
placeable;
var DynamicLightEnvironmentComponent LightEnvironment;
var SkeletalMeshComponent  MyMesh;
var StaticMeshComponent MyMesh2;
var float CamOffsetDistance; //Position on Y-axis to lock camera to
 
simulated event PostBeginPlay()
{
MyMesh.AttachComponentToSocket(MyMesh2, 'Bouboule');
super.PostBeginPlay();
}
//override to make player mesh visible by default
simulated event BecomeViewTarget( PlayerController PC )
{
   local UTPlayerController UTPC;
   Super.BecomeViewTarget(PC);
  if (LocalPlayer(PC.Player) != None)
  {
      UTPC = UTPlayerController(PC);
      if (UTPC != None)
      {
         //set player controller to behind view and make mesh visible
         UTPC.SetBehindView(true);
         SetMeshVisibility(UTPC.bBehindView);
         UTPC.bNoCrosshair = true;
     }
   }
}
simulated function bool CalcCamera( float fDeltaTime, out vector out_CamLoc, out rotator out_CamRot, out float out_FOV )
{
   out_CamLoc = Location;
   out_CamLoc.Y = CamOffsetDistance;
   out_CamRot.Pitch = -1500;
   out_CamRot.Yaw = 16384;
   out_CamRot.Roll = 0;
   return true;
}
simulated singular event Rotator GetBaseAimRotation()
{
   local rotator   POVRot;
   POVRot = Rotation;
   if( (Rotation.Yaw % 65535 > 16384 && Rotation.Yaw % 65535 < 49560) ||
      (Rotation.Yaw % 65535 < -16384 && Rotation.Yaw % 65535 > -49560) )
   {
      POVRot.Yaw = 32768;
   }
   else
   {
      POVRot.Yaw = 0;
   }
   
   if( POVRot.Pitch == 0 )
   {
      POVRot.Pitch = RemoteViewPitch << 8;
   }
   return POVRot;
}   
 
 
defaultproperties
{

CamOffsetDistance=-500.0
 bBehindView=true
bForceBehindView=true 
 
 Begin Object class=SkeletalMeshComponent Name=MyStaticMeshComponent
  Translation=(Z=8.0)
  SkeletalMesh=SkeletalMesh'ScriptedStuff.Perso_GravityGame'
  //Materials[0]=MaterialInstanceConstant'zGameTest.Material.MI_zCrate'
  AnimTreeTemplate=AnimTree'ScriptedStuff.perso_animtree'
  AnimSets(0)=AnimSet'ScriptedStuff.perso_animset'
  LightEnvironment=MyLightEnvironment
  
 End Object
 MyMesh=MyStaticMeshComponent
  Components.Add(MyStaticMeshComponent)
 CollisionComponent=MyStaticMeshComponent
 MyMesh.SetLightEnvironment(LightEnvironment);
 
 
 Begin Object class=StaticMeshComponent Name=MyStaticMeshComponent2
  StaticMesh=StaticMesh'ScriptedStuff.Boulet'
  //Materials[0]=MaterialInstanceConstant'zGameTest.Material.MI_zCrate'
  //AnimTreeTemplate=AnimTree'MyPackage.Journalist_AnimTree'
  //AnimSets(0)=AnimSet'MyPackage.journalistAnim'
  //LightEnvironment=MyLightEnvironment
 End Object
 MyMesh2=MyStaticMeshComponent2
  Components.Add(MyStaticMeshComponent2)
 CollisionComponent=MyStaticMeshComponent2
 
 
 Begin Object Name=CollisionCylinder
  CollisionRadius=+005.000000
  CollisionHeight=+00100.000000
  End Object
  CylinderComponent=CollisionCylinder
 
 bEdShouldSnap=true
 bCollideActors=true
 bBlockActors=true
 

}

Controller :
class GravityGameController extends UTPlayerController;
state PlayerWalking
{
ignores SeePlayer, HearNoise, Bump;
   function ProcessMove(float DeltaTime, vector NewAccel, eDoubleClickDir DoubleClickMove, rotator DeltaRot)
   {
      local Rotator tempRot;
      if( Pawn == None )
      {
         return;
      }
      if (Role == ROLE_Authority)
      {
         // Update ViewPitch for remote clients
         Pawn.SetRemoteViewPitch( Rotation.Pitch );
      }
      Pawn.Acceleration.X = -1 * PlayerInput.aStrafe * DeltaTime * 100 * PlayerInput.MoveForwardSpeed;
      Pawn.Acceleration.Y = 0;
      Pawn.Acceleration.Z = 0;
      
      tempRot.Pitch = Pawn.Rotation.Pitch;
      tempRot.Roll = 0;
      if(Normal(Pawn.Acceleration) Dot Vect(1,0,0) > 0)
      {
         tempRot.Yaw = 0;
         Pawn.SetRotation(tempRot);
      }
      else if(Normal(Pawn.Acceleration) Dot Vect(1,0,0) < 0)
      {
         tempRot.Yaw = 42564;
         Pawn.SetRotation(tempRot);
      }
      CheckJumpOrDuck();
   }
}
function UpdateRotation( float DeltaTime )
{
   local Rotator   DeltaRot, ViewRotation;
   ViewRotation = Rotation;
   // Calculate Delta to be applied on ViewRotation
   DeltaRot.Yaw = Pawn.Rotation.Yaw;
   DeltaRot.Pitch   = PlayerInput.aLookUp;
   ProcessViewRotation( DeltaTime, ViewRotation, DeltaRot );
   SetRotation(ViewRotation);
}   
 
function TriggerTouched()
{
ConsoleCommand("SetGravity -1000");
}

exec function AllegerPawn()
{
ConsoleCommand("SetGravity 2000");
}

exec function reglagePrototype()
{
ConsoleCommand("SetGravity -2000");
}
 
 
defaultproperties
{
bBehindView=true
bForceBehindView=true 
}


I think the part that is in trouble is this one in the Pawn
simulated event BecomeViewTarget( PlayerController PC )
{
   local UTPlayerController UTPC;
   Super.BecomeViewTarget(PC);
  if (LocalPlayer(PC.Player) != None)
  {
      UTPC = UTPlayerController(PC);
      if (UTPC != None)
      {
         //set player controller to behind view and make mesh visible
         UTPC.SetBehindView(true);
         SetMeshVisibility(UTPC.bBehindView);
         UTPC.bNoCrosshair = true;
     }
   }
}
Does anyone have any idea ?
Thanks a lot !
Sign In or Register to comment.