Announcement

Collapse
No announcement yet.

Attach Camera To Socket Help

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Attach Camera To Socket Help

    Hey guys,

    I'm trying to attach a camera to a socket I made using CalcCamera, but its not working. Please help me out ?, It defaults to third person and I want it to be viewed from where I attached the camera.

    Piece of code I want to work!:

    Code:
    /** Name of the Bone/Socket to base the camera on */
        var() name CameraTag;
    
    simulated function bool CalcCamera( float fDeltaTime, out vector out_CamLoc, out rotator out_CamRot, out float out_FOV )
    {
        local vector SocketLoc;
        local rotator SocketRot;
    
    //get the location and rotation of the socket
        Mesh.GetSocketWorldLocationAndRotation(CameraTag, SocketLoc, SocketRot);
    
            //set the cam location and rotation
        out_CamLoc = SocketLoc;
        out_CamRot = SocketRot;
    
        return true;
    }
    
    defaultproperties
    {
        
    //change GunViewSocket to whatever your socket is called
    CameraTag=Eyes
    Game Info Class:

    Code:
    class CaptivityGameInfo extends UTDeathMatch;
    
     
    
    var CaptivityPlayerController currentPlayer;
    
     
    
    function RestartPlayer(Controller aPlayer)
    
    {
    
    super.RestartPlayer(aPlayer);
    
    `Log("Player restarted");
    
    currentPlayer = CaptivityPlayerController(aPlayer);
    
     
    
    currentPlayer.resetMesh();
    
    currentPlayer.rSetBehindView(false);
    
    currentPlayer.rSetCameraMode('ThirdPerson');
    
    }
    
     
    
    simulated function PostBeginPlay() {
    
    local UTDeathMatch Game;
    
    Super.PostBeginPlay();
    
     
    
    Game = UTDeathMatch(WorldInfo.Game);
    
     
    
    if (Game != None)
    
    {
    
    Game.PlayerControllerClass=Class'CaptivityGame.CaptivityPlayerController';
    
    }
    
    }
    
     
    
    defaultproperties
    
    {
    
     
    
    PlayerControllerClass=Class'CaptivityGame.CaptivityPlayerController';
    
    
    bUseClassicHUD=true
     
    //bDelayedStart=false;
    //bRestartdLevel=false;
    Name="Default__CaptivityGameInfo "
    }
    Player Controller Class:

    Code:
    class CaptivityPlayerController extends UTPlayerController;
    
     
    
    // members for the custom mesh
    
    var SkeletalMesh defaultMesh;
    
    var MaterialInterface defaultMaterial0;
    
    var MaterialInterface defaultMaterial1;
    
    var AnimTree defaultAnimTree;
    
    var array<AnimSet> defaultAnimSet;
    
    var AnimNodeSequence defaultAnimSeq;
    
    var PhysicsAsset defaultPhysicsAsset;
    
    
    
     
    
    simulated function PostBeginPlay() {
    
    super.PostBeginPlay();
    
     
    
    //SetCameraMode('ThirdPerson');
    
     
    
    resetMesh();
    
    }
    
     
    
    // Sets the Pawns Mesh to the resources speced in the DefaultProperties
    
    public function resetMesh(){
    
    self.Pawn.Mesh.SetSkeletalMesh(defaultMesh);
    
    self.Pawn.Mesh.SetMaterial(0,defaultMaterial0);
    
    self.Pawn.Mesh.SetMaterial(1,defaultMaterial1);
    
    self.Pawn.Mesh.SetPhysicsAsset(defaultPhysicsAsset );
    
    self.Pawn.Mesh.AnimSets=defaultAnimSet;
    
    self.Pawn.Mesh.SetAnimTreeTemplate(defaultAnimTree );
    
    }
    
    
    
    
    //Called at RestartPlayer by GameType
    
    public function rSetBehindView(bool view){
    
    SetBehindView(view);
    
    }
    
    
    
    // Called at RestartPlayer by GameType
    
    public function rSetCameraMode(name cameraSetting){
    
    SetCameraMode(cameraSetting);
    
    }
    
    
    
    
    state PlayerWalking
    {
    ignores SeePlayer, HearNoise, Bump;
    
       function ProcessMove(float DeltaTime, vector NewAccel, eDoubleClickDir DoubleClickMove, rotator DeltaRot)
       {
          if( Pawn == None )
          {
             return;
          }
    
          if (Role == ROLE_Authority)
          {
             // Update ViewPitch for remote clients
             Pawn.SetRemoteViewPitch( Rotation.Pitch );
          }
    
          Pawn.Acceleration = NewAccel;
    
          CheckJumpOrDuck();
       }
    }
      
    
    DefaultProperties
    
    {
    
    //CameraClass=class 'CaptivityCamera'
    
    defaultMesh=SkeletalMesh'MyPackage.Stanley_Hudson'
    
    defaultAnimTree=AnimTree'MyPackage.Stanley_Hudson_AnimTree'
    
    defaultAnimSet(0)=AnimSet'MyPackage.Stanley_Hudson_AnimSet'
    
    defaultPhysicsAsset=PhysicsAsset'MyPackage.Stanley_Hudson_Physics'
    
    
    //UTHUDBase(myHUD).bCrosshairShow = false
    
    //HUD
     bForceBehindView=false
     Name= "Default__CaptivityPlayerController"
    
    }
    Pawn Class:

    Code:
    class CaptivityPawn extends UTPawn;
    
     
    
    var(NPC) class NPCController;
    
    /** Name of the Bone/Socket to base the camera on */
        var() name CameraTag;
    
    simulated function bool CalcCamera( float fDeltaTime, out vector out_CamLoc, out rotator out_CamRot, out float out_FOV )
    {
        local vector SocketLoc;
        local rotator SocketRot;
    
    //get the location and rotation of the socket
        Mesh.GetSocketWorldLocationAndRotation(CameraTag, SocketLoc, SocketRot);
    
            //set the cam location and rotation
        out_CamLoc = SocketLoc;
        out_CamRot = SocketRot;
    
        return true;
    }
    
    defaultproperties
    {
        
    //change GunViewSocket to whatever your socket is called
    CameraTag=Eyes
       
    WalkingPct=+0.4
    
    CrouchedPct=+0.4
    
    BaseEyeHeight=38.0
    
    EyeHeight=38.0
    
    GroundSpeed=80
    
    AirSpeed=440.0
    
    WaterSpeed=220.0
    
    DodgeSpeed=200.0
    
    DodgeSpeedZ=295.0
    
    AccelRate=2048.0
    
    JumpZ=322.0
    
    CrouchHeight=29.0
    
    CrouchRadius=21.0
    
    AlwaysRelevantDistanceSquared=+1960000.0
    
    //InventoryManagerClass=class'UTGame.UTInventoryManager'
    
    //ControllerClass=class'CaptivityGame.CaptivityPlayerController'
    
    NPCController=class'CaptivityGame.CaptivityPlayerController'
    
    MeleeRange=+20.0
    
    bMuffledHearing=true
    
    Buoyancy=+000.99000000
    
    UnderWaterTime=+00020.000000
    
    bCanStrafe=True
    
    bCanSwim=true
    
    RotationRate=(Pitch=20000,Yaw=20000,Roll=20000)
    
    MaxLeanRoll=2048
    
    AirControl=+0.35
    
    DefaultAirControl=+0.35
    
    bCanCrouch=true
    
    bCanClimbLadders=True
    
    bCanPickupInventory=True
    
    bCanDoubleJump=true
    
    SightRadius=+3000.0
    
    FireRateMultiplier=5.0
    
    MaxMultiJump=3
    
    MultiJumpRemaining=10
    
    MultiJumpBoost=-95.0
    
    SoundGroupClass=class'UTGame.UTPawnSoundGroup'
    
    TransInEffects(0)=class'UTEmit_TransLocateOutRed'
    
    TransInEffects(1)=class'UTEmit_TransLocateOut'
    
    MaxStepHeight=35.0
    
    MaxJumpHeight=69.0
    
    MaxDoubleJumpHeight=87.0
    
    DoubleJumpEyeHeight=43.0
    
    SuperHealthMax=9000
    
    Begin Object Name=WPawnSkeletalMeshComponent
    
    bOwnerNoSee=false
    
    End Object
    
    Name="Default__CaptivityPawn"
    
    }

    #2
    just set the pawn class on your game info to your custom pawn class. You can modify the visibility in the mesh properties instead of having to use the cheat code which may not work due to the cheat manager class.

    Comment


      #3
      whats the difference between a pawn and a custom pawn ?! please explain more ! I've already made a custom pawn ?!

      Comment


        #4
        in your gameinfo defaultproperties

        DefaultPawnClass=class'YourPawn'

        Comment


          #5
          anything thats not done by Epic is usually refered to as custom, so custom pawn means a class created by the user that extends pawn, gamepawn, simplepawn, udkpawn, or utpawn

          Comment


            #6
            *Solved! Thank you TEGLEG ! I owe you !

            Comment

            Working...
            X