Announcement

Collapse
No announcement yet.

custom pawn coded doesnt appear to be getting compiled properly

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

    custom pawn coded doesnt appear to be getting compiled properly

    OK im fairly sure my pawn isn't getting compiled correctly - i know this probably isn't the case but i can not see what i've done wrong here

    even when i add the archetype to a level in Unreal, nothing shows up

    has anyone ever had this issue before ?


    here is my pawn class :

    Code:
    class AK_Pawn extends Pawn;
    
    // Camera Properties
    var bool bLockCamX, bLockCamY, bLockCamZ;
    var CameraActor CurrentTriggerCam, PreviousCamera, CurrentCamera, NextCamera; // Each pawn needs his own cameras
    var Vector FacingDir; // Used to work which way we are facing
    
    // Trigger Cam Properties
    var AK_TriggerCamVolume CurrentTriggerCamVolume;
    
    // personal dynamic lighting - probs wont need
    var(Pawn) const DynamicLightEnvironmentComponent LightEnviroment;
    
    // Archetype Properties
    var(AK_Pawn) float RunningSpeed;
    var(AK_Pawn) float WalkingSpeed;
    var(AK_Pawn) float JumpHeight;
    var(AK_Pawn) float TakeOffDelay;
    var(AK_Pawn) float FallSpeed;
    var(AK_Pawn) float LandDelay;
    var(AK_Pawn) float OffsetLerpSpeed;
    var(AK_Pawn) name AimNodeName;
    var(AK_Pawn) const Name WeaponSocketName;
    var(AK_Pawn) const float CrouchingHeightOverride<DisplayName=Crouch Height>;
    var(AK_Pawn) const float CrouchingRadiusOverride<DisplayName=Crouch Radius>;
    var(AK_Pawn) const float CollisionHeightOverride<DisplayName=Collision Height>;
    var(AK_Pawn) const float CollisionRadiusOverride<DisplayName=Collision Radius>;
    
    var AnimNodeAimOffset AimNode;
    var float forcedLocY, DesiredYaw, CurrentYaw;
    var AK_Playercontroller akController;
    var string CharacterName;
    var bool bLandedPause; // pause the character when he has landed
    var Actor CurrentActiveCheckPoint; // last touched/activated checkpoint for this characters
    
    // ===================================================
    
    
    simulated function PostBeginPlay()
    {
    	super.PostBeginPlay();
    	GroundSpeed = WalkingSpeed;
    	forcedLocY = Location.Y;
    
    	CrouchHeight = CrouchingHeightOverride;
    	CrouchRadius = CrouchingRadiusOverride;
    	SetAKController();
    }
    
    event Tick(float DeltaTime)
    {
    	local vector tempLocation;
    
    super.Tick(DeltaTime);
    	tempLocation = Location;
    	FacingDir = Vector(Rotation);
    //clamp pawn on the Y axis
    	tempLocation.Y = forcedLocY;
    	SetLocation(tempLocation);
    
    	if(CurrentTriggerCamVolume != none)
    		NextCamera = CurrentTriggerCamVolume.cameraActor;
    }
    
    
    function SetAKController()
    {
    	akController = AK_Playercontroller(Controller);
    }
    
    
    	// Movement / Rotation
    
    simulated function FaceRotation(Rotator NewRotation, float DeltaTime)
    {
    	local Rotator FacingRotation;
    	local int CurrentPitch;
    
    	akController = AK_Playercontroller(Controller);
    	if(akController != none)
    	{
    		if(NewRotation.Yaw != 0)
    			DesiredYaw = NewRotation.Yaw;
    		if(CurrentYaw != DesiredYaw)
    			CurrentYaw = DesiredYaw;
    	
    		CurrentPitch = Clamp(CurrentPitch + NewRotation.Pitch, ViewPitchMin, ViewPitchMax);
    		
    		if(CurrentPitch > 0.f)
    			AimNode.Aim.Y = float(CurrentPitch) / ViewPitchMax; // aim up
    		else if(CurrentPitch < 0.f)
    			AimNode.Aim.Y = float(CurrentPitch) / ViewPitchMin; // aim down
    		else
    			AimNode.Aim.Y = 0.f; // aim straight on
    
    		FacingRotation.Pitch = int(AimNode.Aim.Y);
    		FacingRotation.Yaw = CurrentYaw;
    		FacingRotation.Roll = 0;
    		SetRotation(FacingRotation);
    	}
    	
    }
    
    event Landed(Vector HitNormal, Actor FloorActor)
    {
    	super.Landed(HitNormal, FloorActor);
    }
    
    
    // Run
    exec simulated function Run(bool bRun)
    {
    	GroundSpeed = bRun ? RunningSpeed : WalkingSpeed;
    }
    
    // Jump
    function bool DoJump(bool bUpdating)
    {
    	if(bJumpCapable && !bIsCrouched && !bWantsToCrouch && (Physics==PHYS_Walking || Physics == PHYS_Ladder || Physics == PHYS_Spider))
    	{
    		if(Physics == PHYS_Spider)
    			Velocity = JumpHeight * Floor;
    		else
    			Velocity.Z = JumpHeight;
    
    		if(Base != none && !Base.bWorldGeometry && Base.Velocity.Z > 0.f)
    			Velocity.Z += Base.Velocity.Z;
    
    		SetPhysics(PHYS_Falling);
    		return true;
    	}
    	return false;
    }
    
    simulated function Rotator GetAdjustedAimFor(Weapon w, Vector StartFireLoc)
    {
    	local Vector SocketLocation;
    	local Rotator SocketRotation;
    	local AK_Weapon akWeapon;
    	local SkeletalMeshComponent WeaponSkeletalMeshComponent;
    
    	akWeapon = AK_Weapon(Weapon);
    	if(akWeapon != none)
    	{
    		WeaponSkeletalMeshComponent = SkeletalMeshComponent(akWeapon.Mesh);
    		if(WeaponSkeletalMeshComponent != none && WeaponSkeletalMeshComponent.GetSocketByName(akWeapon.MuzzleSocketName) != none)
    		{
    			WeaponSkeletalMeshComponent.GetSocketWorldLocationAndRotation(akWeapon.MuzzleSocketName, SocketLocation, SocketRotation);
    			return SocketRotation;
    		}
    	}
    
    	return Rotation;
    }
    
    simulated event Vector GetWeaponStartTraceLocation(optional Weapon CurrentWeapon)
    {
        local Vector SocketLocation;
        local Rotator SocketRotation;
        local AK_Weapon akWeapon;
        local SkeletalMeshComponent WeaponSkeletalMeshComponent;
    
        akWeapon = AK_Weapon(Weapon);
        if (akWeapon != none)
        {
            WeaponSkeletalMeshComponent = SkeletalMeshComponent(akWeapon.Mesh);
            if (WeaponSkeletalMeshComponent != none && WeaponSkeletalMeshComponent.GetSocketByName(akWeapon.MuzzleSocketName) != none)
            {
                WeaponSkeletalMeshComponent.GetSocketWorldLocationAndRotation(akWeapon.MuzzleSocketName, SocketLocation, SocketRotation);
                return SocketLocation;
            }
        }
    
        return Super.GetWeaponStartTraceLocation(CurrentWeapon);
    }
    
    
    
    	// Anims
    event PostInitAnimTree(SkeletalMeshComponent SkelComp)
    {
    	`log("init anim tree");
    	if(SkelComp == Mesh)
    	{
    		AimNode = AnimNodeAimOffset(Mesh.FindAnimNode('AimNode'));
    	}
    }
    
    
    
    
    	// Weapons/Spells
    function StartFire(byte FireModeNum)
    {
    }
    
    exec function StartAltFire(optional byte FireModeNum)
    {
    
    }
    
    	// Camera
    simulated function bool CalcCamera( float fDeltaTime, out vector out_CamLoc, out rotator out_CamRot, out float out_FOV )
    {
    	return false;
    }
    
    
    DefaultProperties
    {
    	FallSpeed = 0
    	    // remove the sprite component
    	Components.Remove(Sprite);
        bCollideActors=true
    
        // create a light enviroment for the pawn
        Begin Object Class=DynamicLightEnvironmentComponent Name=MyLightEnviroment
            bSynthesizeSHLight=true
            bIsCharacterLightEnvironment=true
            bUseBooleanEnvironmentShadowing=false
        End Object
        Components.Add(MyLightEnviroment)
        LightEnviroment=MyLightEnviroment
    	
        // Create a skeletal mesh component for the pawn
        Begin Object Class=SkeletalMeshComponent Name=SkelComp
            bCacheAnimSequenceNodes=false
            AlwaysLoadOnClient=true
            AlwaysLoadOnServer=true
            CastShadow=true
            BlockRigidBody=true
    		BlockActors=true
    		CollideActors=true
            bUpdateSkelWhenNotRendered=true
            bIgnoreControllersWhenNotRendered=true
            bUpdateKinematicBonesFromAnimation=true
            bCastDynamicShadow=true
            RBChannel=RBCC_Untitled3
            RBCollideWithChannels=(Untitled3=true)
            LightEnvironment=MyLightEnvironment
            bOverrideAttachmentOwnerVisibility=true
            bAcceptsDynamicDecals=false
            bHasPhysicsAssetInstance=true
            TickGroup=TG_PreAsyncWork
            MinDistFactorForKinematicUpdate=0.2f
            bChartDistanceFactor=true
            RBDominanceGroup=20
            Scale=1.f
            bAllowAmbientOcclusion=false
            bUseOnePassLightingOnTranslucency=true
            bPerBoneMotionBlur=true
        end object
    	Mesh=SkelComp
        Components.Add(SkelComp)
    	
    }
    i cant see anything wrong with this, i should be able to create an archetype of this from the content browser and dump it into a level where i can set the Skel Mesh

    PostInitAnimTree() never gets called either so i assuming something is going wrong when i spawn the pawn too
    here is how i spawn mypawn
    Code:
    class MyGameInfo extends SimpleGame;
    var() const archetype AK_Pawn ArchetypeAKPawn;
    
    function RestartPlayer(Controller NewPlayer)
    {
    NewPlayer.pawn = Spawn(ArchetypeAKPawn.Class, , , PlayerStart.Location, PlayerStart.StartRotation, ArchetypeAKPawn);
    }
    defaultproperties
    {
    ArchetypeAKPawn = AK_Pawn'Package.akPawn'
    }
    inside UDK i create an archetype of my AK_Pawn and set some properties

    #2
    cant explain it but deleting my old package and recreating the archetypes worked
    not a clue..
    that previous package must have become corrupted in someway

    can this thread be closed?

    Comment

    Working...
    X