Announcement

Collapse
No announcement yet.

player has no weapon이 뜹니다.

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

    player has no weapon이 뜹니다.

    컴파일이 최종적으로 성공했고 그 후에 언리얼ed를 실행해서 게임타입 조정 후 모바일 프리뷰어를 통해 실행하였습니다.
    그러나 제가 만약 무기를 소지하고있지않으면 broadcast로 player has no weapon이 뜨게 했던것이 떠버렸습니다.

    밑에는 소스들입니다.

    [exampleCh3_2Game.uc]
    Code:
    class exampleCh3_2Game extends FrameworkGame;
    
    event OnEngineHasLoaded(){
    	WorldInfo.Game.Broadcast(self,"te1 Type Active-Enegine Has Loaded!!!");
    }
    
    function bool PreventDeath(Pawn KilledPawn, Controller Killer, class<DamageType> DamageType, vector HitLocation){
    	return true;
    }
    
    static event class<GameInfo> SetGameType(string MapName, string Options,string Portal){
    return super.SetGameType(MapName,Options,Portal);
    }   
    
    DefaultProperties
    {
    	PlayerControllerClass=class'exampleCh3_2.exampleCh3_2PC'
    	DefaultPawnClass=class'Jazz2Pawn'
    	HUDType=class'UDKBase.UDKHUD'
    
    	bRestartLevel=false
    	bWaitingToStartMatch=true
    	bDelayedStart=false
    }
    [exampleCh3_2PC.uc]
    Code:
    class exampleCh3_2PC extends simplePC;
    
    function bool SwipeZoneCallback(MobileInputZone Zone,float DeltaTime,int Handle,ETouchType EventType,Vector2D TouchLocation){
    	local bool retval;
    	retval=true;
    
    	if(EventType==Touch_Began){
    		//폰의 무기를 발사한다.
    		StartFire(0);
    	}else if(EventType==Touch_Moved){
    		
    	}else if(EventType==Touch_Ended){
    		StopFire(0);
    	}
    	return retval;
    }
    
    function SetupZones(){
    	Super.SetupZones();
    
    	if(MPI!=None&&WorldInfo.GRI.GameClass!=none){
    		LocalPlayer(Player).ViewportClient.GetViewportSize(ViewportSize);
    		if(FreeLookZone!=none){
    			FreeLookZone.OnProcessInputDelegate=SwipeZoneCallback;
    		}
    	}
    }
    
    function PlaceWeapon(){
    	//1인칭
    	local vector WeaponLocation;
    	local Rotator WeaponRotation,TempRot;
    	local Weapon TestW;
    	local vector WeaponAimVect;
    
    	WeaponRotation.yaw=-16000;//90도 회전=오프셋
    
    	TempRot=Pawn.GetBaseAimRotation();
    	WeaponRotation.pitch=TempRot.roll;
    	WeaponRotation.yaw+=TempRot.yaw;
    	WeaponRotation.roll-=TempRot.pitch;
    	//무기의 로컬 축 방향으로 인해 방향을 전환시킨다.
    
    	WeaponAimVect=Normal(Vector(TempRot));
    	WeaponLocation=Pawn.Location+(40*WeaponAimVect)+vect(0,0,30);
    
    	TestW=Pawn.Weapon;
    
    	if(TestW!=None){
    		TestW.SetLocation(WeaponLocation);
    		TestW.SetRotation(WeaponRotation);
    	}else{
    		WorldInfo.Game.Broadcast(self,"Player has no weapon!!!!!!");
    	}
    }
    
    function PlayerTick(float DeltaTIme){
    	Super.PlayerTick(DeltaTime);
    	PlaceWeapon();
    }
    
    DefaultProperties
    {
    }
    [jazz2Pawn.uc]
    Code:
    class Jazz2Pawn extends SimplePawn;
    
    var Inventory MainGun;
    
    function AddDeaultInventory(){
    	MainGun=InvManager.CreateInventory(class'JazzWeapon2');
    
    	MainGun.SetHidden(false);
    
    	Weapon(MainGUn).FireOffset=vect(0,0,-70);
    }
    
    DefaultProperties
    {
    	InventoryManagerClass=class'WeaponIM1'
    }
    [JazzBullet2.uc]
    Code:
    class JazzBullet2 extends projectile;
    
    simulated function Explode(vector HitLocation,vector HitNormal){
    	SetPhysics(Phys_Falling);
    }
    
    function Init(Vector Direction){
    	super.Init(Direction);
    	RandSpin(90000);
    }   
    
    DefaultProperties
    {
    	Begin Object Class=StaticMeshComponent Name=Bullet
    		StaticMesh=StaticMesh'Castle_Assets.Meshes.SM_RiverRock_01'
    		Scale3D=(X=0.300000,Y=0.30000,Z=0.3000)
    	End Object
    	Components.Add(Bullet)
    
    	Begin Object Class=ParticleSystemComponent Name=BulletTrail
    		Template=ParticleSystem'Castle_Assets.FX.P_FX_Fire_SubUV_01'
    	End Object
    	Components.Add(BulletTrail)
    
    	MaxSpeed=+05000.000000
    	Speed=+05000.000000
    }
    [JazzWeapon2.uc]
    Code:
    class JazzWeapon2 extends Weapon;
    
    DefaultProperties
    {
    	Begin Object Class=SkeletalMeshComponent Name=FirstPersonMesh
    		SkeletalMesh=SkeletalMesh'KismetGame_Assets.Anims.SK_JazzGun'
    	End Object
    	Mesh=FirstPersonMesh
    	Components.Add(FirstPersonMesh);
    
    	Begin object Class=SkeletalMeshComponent Name=PickupMesh
    		SkeletalMesh=SkeletalMesh'KismetGame_Assets.Anims.SK_JazzGun'
    	End Object
    	DroppedPickupMesh=PickupMesh
    	PickupFactoryMesh=PickupMesh
    
    	WeaponFireTypes(0)=EWFT_Projectile
    	WeaponFireTypes(1)=EWFT_NONE
    
    	WeaponProjectiles(0)=class'JazzBullet2'
    	WeaponProjectiles(1)=class'JazzBullet2'
    
    	FiringStatesArray(0)=WeaponFiring
    	FireInterval(0)=0.25
    	Spread(0)=0
    }
    [WeaponIM1.uc]
    Code:
    class WeaponIM1 extends InventoryManager;
    
    
    DefaultProperties
    {
    	PendingFire(0)=0
    	PendingFire(1)=0
    }

    왜 폰이 무기를 가지고있지않는 상태로 시작하게되나요?

    #2
    웨폰 시스템 테크니컬 가이드

    [YourPlayerController]
    Code:
    event Possess(Pawn aPawn, bool bVehicleTransition)
    {
          super.Possess(aPawn, bVehicleTransition);
          aPawn.SetActiveWeapon(Spawn(class'JazzWeapon2'));
    }
    직접 쥐어 줘 보십시오.

    Comment


      #3
      [Jazz2Pawn.uc] 파일에서 오타가났었네요
      function AddDeaultInventroy() -> function AddDefaultInventory()

      f가 빠졌는데도 컴파일시에는 오류하나 안뜨길래 나중에서야 꼼꼼히 확인해보니 이런 오타가났었네요.

      이 코드도 잘 알아두겠습니다.
      event Possess(Pawn aPawn, bool bVehicleTransition)
      {
      super.Possess(aPawn, bVehicleTransition);
      aPawn.SetActiveWeapon(Spawn(class'JazzWeapon2'));
      }

      질문드려 죄송합니다.

      Comment

      Working...
      X