Hello guys,
I am developing a true first person shooter game for OculusVR.
I successfully implemented full-body awareness.
I implemented custom weapons as well. The only problem right now is that the weapons are not casting shadow.
Here is the screenshot:

My Pawn Class
My Custom Weapon Class
Weapon Attachment Class
I USED UTWEAPONS LIKE LINKGUN AND ROCKET LAUNCHER..SHADOW STILL NOT VISIBLE...IT MEANS PROBLEM IS WITH MY PAWN CLASS??
I HAVE NO IDEA WHY SHADOW IS NOT CASTING FOR THE WEAPON!!! NEED HELP!!
SPRINTING LOGIC SEEMS TO BE BROKEN AS WELL
I am developing a true first person shooter game for OculusVR.
I successfully implemented full-body awareness.
I implemented custom weapons as well. The only problem right now is that the weapons are not casting shadow.
Here is the screenshot:

My Pawn Class
Code:
class GA_Pawn extends UTPawn; var float WalkSpeed; var float SprintSpeed; var Rotator CameraRot; var bool bFixedTracking; var(TFP) name EyeSocket; var SkeletalMeshComponent HeadMesh; simulated event PostBeginPlay() { `Log("Custom Pawn up"); //debug super.PostBeginPlay(); } function AddDefaultInventory() { InvManager.CreateInventory(class'SDWeap_MG'); } simulated function bool CalcCamera( float fDeltaTime, out vector out_CamLoc, out rotator out_CamRot, out float out_FOV ) { // Handle the fixed camera if (bFixedView) { out_CamLoc = FixedViewLoc; out_CamRot = FixedViewRot; } else { if ( !IsFirstPerson() ) // Handle BehindView { CalcThirdPersonCam(fDeltaTime, out_CamLoc, out_CamRot, out_FOV); } else { // By default, we view through the Pawn's eyes.. GetActorEyesViewPoint( out_CamLoc, out_CamRot ); } if ( UTWeapon(Weapon) != none) { UTWeapon(Weapon).WeaponCalcCamera(fDeltaTime, out_CamLoc, out_CamRot); } } return true; } simulated function SetHeadVisibility() { local bool IsVisible; local GA_PlayerController Ga_PC; Ga_PC = GA_PlayerController(Controller); if (Ga_PC != None) IsVisible = (Ga_PC.bBehindView || bFixedView || Ga_PC.bDebugFreeCam); // Handle the HeadMesh visibility if (HeadMesh != None) HeadMesh.SetOwnerNoSee(!IsVisible); } simulated event Vector GetPawnViewLocation() { local vector viewLoc; // no eye socket? No way I can tell you a location based on this socket then... if (EyeSocket == '') return Location + BaseEyeHeight * vect(0,0,1); SetMeshVisibility(true); SetWeaponAttachmentVisibility(false); Mesh.GetSocketWorldLocationAndRotation(EyeSocket, viewLoc); return viewLoc; } simulated function SetMeshVisibility(bool bVisible) { local UTCarriedObject Flag; // Handle the main player mesh if (Mesh != None) { Mesh.SetOwnerNoSee(!bVisible); } SetOverlayVisibility(bVisible); // Handle any weapons they might have SetWeaponVisibility(true); // realign any attached flags foreach BasedActors(class'UTCarriedObject', Flag) { HoldGameObject(Flag); } } /* Dying Instead of switching to a third person view, match the camera to the location and rotation of the eye socket. */ simulated State Dying { // skip UTPawn's fancy damage/third person views simulated function bool CalcCamera( float fDeltaTime, out vector out_CamLoc, out rotator out_CamRot, out float out_FOV ) { return Global.CalcCamera(fDeltaTime, out_CamLoc, out_CamRot, out_FOV); } simulated event rotator GetViewRotation() { local vector out_Loc; local rotator out_Rot; // no eye socket? No way I can tell you a rotation based on this socket then... if (EyeSocket == '') return Global.GetViewRotation(); // non-state version please Mesh.GetSocketWorldLocationAndRotation(EyeSocket, out_Loc, out_Rot); return out_Rot; } } function Tick(float DeltaTime) { SetHeadVisibility(); //`Log("Global Rot: "$Rotation); //`Log("Local Rot: "$LocalVect); } exec function StartSprint() { local EMoveDir moveDir; local float amount; moveDir = MovingWhichWay(amount); if(moveDir == EMoveDir.MD_Forward) { `Log("Sprinting "); GroundSpeed=SprintSpeed; } //`Log(P.Acceleration); } exec function StopSprint() { GroundSpeed=WalkSpeed; } simulated function SetCharacterClassFromInfo(class<UTFamilyInfo> Info); DefaultProperties { EyeSocket=Eyes WalkSpeed=+00250.000000 GroundSpeed=+00250.000000 SprintSpeed=+00450.000000 SoundGroupClass=class'SD_PawnSoundGroup' Begin Object Name=WPawnSkeletalMeshComponent bOwnerNoSee=False AnimTreeTemplate=AnimTree'CH_AnimHuman_Tree.AT_CH_Human' //AnimTreeTemplate=AnimTree'CH_TFP_Male.Tree.AT_CH_TFP' SkeletalMesh=SkeletalMesh'Peacock.Test_Peacock' //SkeletalMesh=SkeletalMesh'CH_TFP_Male.Mesh.tfpMale_Body' PhysicsAsset=PhysicsAsset'CH_AnimCorrupt.Mesh.SK_CH_Corrupt_Male_Physics' AnimSets(0)=AnimSet'CH_AnimHuman.Anims.K_AnimHuman_BaseMale' AnimSets(1)=AnimSet'CH_AnimHuman.Anims.K_AnimHuman_AimOffset' //PhysicsAsset=PhysicsAsset'CH_TFP_Male.Mesh.tfpMale_Physics' bUpdateSkelWhenNotRendered=true bIgnoreControllersWhenNotRendered=false bTickAnimNodesWhenNotRendered=true bUpdateKinematicBonesFromAnimation=true End Object Mesh=WPawnSkeletalMeshComponent Components.Add(WPawnSkeletalMeshComponent) Begin Object Class=SkeletalMeshComponent Name=WHeadPawnSkeletalMeshComponent bCacheAnimSequenceNodes=FALSE AlwaysLoadOnClient=true AlwaysLoadOnServer=true CastShadow=true BlockRigidBody=TRUE bUpdateSkelWhenNotRendered=true bIgnoreControllersWhenNotRendered=false bTickAnimNodesWhenNotRendered=true bUpdateKinematicBonesFromAnimation=true bCastDynamicShadow=true Translation=(Z=0.0) RBChannel=RBCC_Untitled3 RBCollideWithChannels=(Untitled3=true) LightEnvironment=MyLightEnvironment bOverrideAttachmentOwnerVisibility=true bAcceptsDynamicDecals=FALSE bHasPhysicsAssetInstance=true TickGroup=TG_PreAsyncWork MinDistFactorForKinematicUpdate=0.2 bChartDistanceFactor=true //bSkipAllUpdateWhenPhysicsAsleep=TRUE RBDominanceGroup=20 Scale=1.0 // Nice lighting for hair bUseOnePassLightingOnTranslucency=TRUE bPerBoneMotionBlur=true SkeletalMesh=SkeletalMesh'CH_TFP_Male.Mesh.tfpMale_Head' // Assign the parent animation component to the head skeletal mesh component. This ensures that // the pawn animates as if it was one skeletal mesh component. ParentAnimComponent=WPawnSkeletalMeshComponent // Assign the shadow parent component to the head skeletal mesh component. This is used to speed up // the rendering of the shadow for this pawn and to prevent shadow overlaps from occur. ShadowParent=WPawnSkeletalMeshComponent // can't see own head bOwnerNoSee=true // but make sure our owner can still see our shadow... bCastHiddenShadow=true End Object HeadMesh=WHeadPawnSkeletalMeshComponent Components.Add(WHeadPawnSkeletalMeshComponent) }
My Custom Weapon Class
Code:
class SDWeap_MG extends AimableWeaponClass; var int ClipSize; var bool isReloading; simulated function bool CanReload() { return false; } simulated function LoadMag(); simulated function bool NeedsReload() { return false; } exec function Reload() { if(CanReload()) { GotoState('Reloading'); } } simulated function WeaponEmpty() { if(MaxAmmoCount > 0 || AmmoCount > 0) { GotoState('Active'); return; } if ( Instigator != none && Instigator.IsLocallyControlled() ) { Instigator.InvManager.SwitchToBestWeapon( true ); } } function int AddAmmo( int Amount ) { AmmoCount = Clamp(AmmoCount + Amount,0,AmmoCount); // check for infinite ammo if (AmmoCount <= 0 && (UTInventoryManager(InvManager) == None || UTInventoryManager(InvManager).bInfiniteAmmo)) { AmmoCount = MaxAmmoCount; } return AmmoCount; } simulated state Active { simulated function Tick(float DeltaTime) { global.Tick(DeltaTime); if(NeedsReload()) { GotoState('Reloading'); return; } } simulated function bool NeedsReload() { return AmmoCount < 1 && MaxAmmoCount > 0; } simulated function bool CanReload() { return (MaxAmmoCount > 0 && AmmoCount < ClipSize && !isReloading); } } simulated state Reloading { simulated function BeginState(name PreviousStateName) { super.BeginState(PreviousStateName); LoadMag(); } simulated function ReloadFinish() { MaxAmmoCount = MaxAmmoCount + AmmoCount; AmmoCount = AvailableAmmo(); MaxAmmoCount = MaxAmmoCount - AmmoCount; GotoState('Active'); } function int AvailableAmmo() { if(ClipSize > MaxAmmoCount) return MaxAmmoCount; else return ClipSize; } simulated function LoadMag() { AgentGame(WorldInfo.Game).Broadcast(self, "Reloading!!"); isReloading = true; //Play Animation PlayWeaponAnimation('WeaponZoomIn', 2.5, false); SetTimer(1.0, false, 'ReloadFinish'); } simulated function EndState(name NextStateName) { ClearTimer('ReloadFinish'); isReloading = false; } } DefaultProperties { AmmoCount=30 MaxAmmoCount=20 ClipSize=30 isReloading=false Begin Object class=AnimNodeSequence Name=MeshSequenceA End Object AttachmentClass=class'MyMod.SDAttachment_MG' Begin Object Name=FirstPersonMesh SkeletalMesh=SkeletalMesh'gaz661-darkarts3dweapons.Mesh.m-60-mk6' AnimSets(0)=AnimSet'gaz661-darkarts3dweapons.Anims.m60_mk6_AnimSet' AnimSets(1)=AnimSet'gaz661-darkarts3dweapons.Anims.m60_mk6_AnimSet' Animations=MeshSequenceA Rotation=(Yaw=-16384) FOV=60.0 Scale=1.0 bCastDynamicShadow=true CastShadow=true bCastHiddenShadow=true ShadowParent=Mesh End Object FireInterval(0)=0.15 MuzzleFlashSocket=MF MuzzleFlashPSCTemplate=ParticleSystem'gaz661-darkarts3dweapons.Effects.m60mk6MF' MuzzleFlashDuration=0.33 WeaponFireAnim(0)=WeaponFire WeaponFireSnd(0)=SoundCue'gaz661-darkarts3dweapons.Sounds.machineghunfire' Begin Object Name=PickupMesh SkeletalMesh=SkeletalMesh'gaz661-darkarts3dweapons.Mesh.m-60-mk6' Scale=0.9 bCastDynamicShadow=true CastShadow=true bCastHiddenShadow=true End Object }
Code:
class SDAttachment_MG extends UTWeaponAttachment; defaultproperties { WeaponClass=class'SDWeap_MG' Begin Object class=AnimNodeSequence Name=MeshSequenceA End Object FireAnim=WeaponFire Begin Object Name=SkeletalMeshComponent0 SkeletalMesh=SkeletalMesh'gaz661-darkarts3dweapons.Mesh.m-60-mk6' Animations=MeshSequenceA AnimSets(0)=AnimSet'gaz661-darkarts3dweapons.Anims.m60_mk6_AnimSet' AnimSets(1)=AnimSet'gaz661-darkarts3dweapons.Anims.m60_mk6_AnimSet' CastShadow=true bCastDynamicShadow=true Scale=1.0 End Object DefaultImpactEffect=(ParticleTemplate=ParticleSystem'gaz661-darkarts3dweapons.Effects.m60Impact',DecalMaterials=(MaterialInstanceTimeVarying'WP_RocketLauncher.Decals.MITV_WP_RocketLauncher_Impact_Decal01'),DecalWidth=12.0,DecalHeight=12.0,Sound=SoundCue'gaz661-darkarts3dweapons.Sounds.bullethit1') BulletWhip=SoundCue'A_Weapon_ShockRifle.Cue.A_Weapon_SR_WhipCue' bMakeSplash=true MuzzleFlashSocket=MF MuzzleFlashPSCTemplate=ParticleSystem'gaz661-darkarts3dweapons.Effects.m60mk6MF' MuzzleFlashDuration=0.33 MuzzleFlashLightClass=class'darkarts3d.m60_mk6_mflight' WeapAnimType=EWAT_Default }
I USED UTWEAPONS LIKE LINKGUN AND ROCKET LAUNCHER..SHADOW STILL NOT VISIBLE...IT MEANS PROBLEM IS WITH MY PAWN CLASS??
I HAVE NO IDEA WHY SHADOW IS NOT CASTING FOR THE WEAPON!!! NEED HELP!!
SPRINTING LOGIC SEEMS TO BE BROKEN AS WELL
Comment