Announcement

Collapse
No announcement yet.

Pocketlight (spotlight) attach to player

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

    Pocketlight (spotlight) attach to player

    i have attach an Spotlight to a player as a pocket light but if i look up with crosshair the light wil not move up its wil only follow the player and the

    only up and down left and right its work and follow good

    #2
    You actually answered the question yourself.
    You attached a light to the PLAYER, while you should actually create a spotlight as a weapon class actually, so you can pick it up and use it like a gun.

    Comment


      #3
      yes but i have a problem if i look up with the pocket lamp then the spotlight is not gone up.


      You can see here what i mean http://www.youtube.com/watch?v=Cl7y-mQXGQE

      ignore the begin of it. you see what i mean if its dark

      Comment


        #4
        attach the spotlight to B_RightHand in the attach bone box. the player body does not move up and down only the hand of the weapon

        Comment


          #5
          if i add B_RightHand in bone box spotlight does not working

          Comment


            #6
            go to kismet the go to NewEvent>PLayer>PlayerSpawned then NewAction>Actor> Attach to actor
            connect playerspawned to attach to actor, then Newvariable>Player>Player
            in the target put player and uncheck "Allplayers?" And for attacthment select your spotlight movable and then right click in kismet and select NewObject Var using spotlightmovable. attacth the spotlight to attachment and for bone name in the attach to actor put "b_RightHand" without quotes.
            if it doesnt work try it in 3rd person, i think it might work in third person hit "tilde" ( ~ ) button and put "behindview 1" without quotes and see if it works. if it doesnt work in first person and works only in third person , then youll have to create a weapon that just emits a spotlight.

            Comment


              #7
              its working but only in behindview how can i do this first person?

              Comment


                #8
                Edit: This was created in UT3, so don't just copy and paste all of the code into UDK.

                Using Unreal Learning #5: Attachments as a base, I originally created 2 weapons(both using the flakcannon as the base weapon) that had a spotlight attached to it.
                One had the light working in 1st person, not 3rd, while the other had it working in 3rd person, and not 1st. So today, I had a look at them and got one to work in both 1st and 3rd person.
                Here's my code: (ignore the creative names )
                Code:
                class UTWeap_LightFlak extends UTWeap_FlakCannon;
                
                var Color LightColor;
                var float LightScale;
                var SpotLightComponent LightAttachment;
                
                simulated function PostBeginPlay()
                {
                		LightAttachment = new(self)class'SpotLightComponent';
                		LightAttachment.SetLightProperties(LightScale, LightColor);
                		LightAttachment.CastDynamicShadows = true;
                		LightAttachment.SetEnabled(true);
                		if ( LightAttachment != None )
                		{
                			SkeletalMeshComponent(Mesh).AttachComponentToSocket(LightAttachment,MuzzleFlashSocket);
                		}
                
                	super.PostbeginPlay();
                }
                
                /*simulated function CustomFire()
                {
                	if ( LightAttachment != None )
                	{
                		if (LightAttachment.bEnabled)
                		{
                			LightAttachment.SetEnabled(false);
                		}
                		else
                			LightAttachment.SetEnabled(true);
                	}
                }*/
                
                defaultproperties
                {
                	LightColor=(R=255,G=255,B=255)
                	LightScale=1.0
                	AttachmentClass=class'LightWeapon.UTAttachment_FlakLight'
                }
                That's the weapon. The commented out code is a switch to toggle the light on/off when you fire; it uses ammo however, so you'd have to look into that if you wanted to change it. Having said that, the weapon does still toggle the light, probably due to the code in the attachment. It's been a while since I actually created these.
                Code:
                class UTAttachment_FlakLight extends UTattachment_FlakCannon;
                
                var Color LightColor;
                var float LightScale;
                var SpotLightComponent LightAttachment;
                
                simulated function PostBeginPlay()
                {
                		LightAttachment = new(self)class'SpotLightComponent';
                		LightAttachment.SetLightProperties(LightScale, LightColor);
                		LightAttachment.CastDynamicShadows = true;
                		LightAttachment.SetEnabled(true);
                		if ( LightAttachment != None )
                		{
                			Mesh.AttachComponentToSocket(LightAttachment,MuzzleFlashSocket);
                		}
                
                	super.PostbeginPlay();
                }
                simulated function ThirdPersonFireEffects(vector HitLocation)
                {
                	ToggleFlashLight();
                	super.ThirdPersonFireEffects(HitLocation);
                }
                
                simulated function ToggleFlashLight()
                {
                	if ( LightAttachment != None )
                	{
                		if (LightAttachment.bEnabled)
                		{
                			LightAttachment.SetEnabled(false);
                		}
                		else
                			LightAttachment.SetEnabled(true);
                	}
                }
                defaultproperties
                {
                	LightColor=(R=255,G=255,B=255)
                	LightScale=1.0
                
                	Begin Object Name=SkeletalMeshComponent0
                		SkeletalMesh=SkeletalMesh'WP_FlakCannon.Mesh.SK_WP_FlakCannon_3P_Mid'
                		AnimSets[0]=AnimSet'WP_FlakCannon.Anims.K_WP_FlakCannon_3P_Base'
                	End Object
                
                	WeaponClass=class'LightWeapon.UTWeap_FlakLightAtt'
                
                	MuzzleFlashSocket=MuzzleFlashSocket
                	MuzzleFlashPSCTemplate=ParticleSystem'WP_FlakCannon.Effects.P_WP_FlakCannon_3P_Muzzle_Flash'
                	MuzzleFlashAltPSCTemplate=ParticleSystem'WP_FlakCannon.Effects.P_WP_FlakCannon_3P_Muzzle_Flash'
                	MuzzleFlashLightClass=class'UTGame.UTRocketMuzzleFlashLight'
                	MuzzleFlashDuration=0.33
                
                	FireAnim=WeaponFire
                }
                And that's the attachment.
                The reason it needs to have it in the attachment as well, is because the attachment deals with the 3rd person effects, while the weapon deals with the 1st person effects.

                In the attachment's defaultproperties, use your weapon class instead of mine in this line:
                WeaponClass=

                In the weapon's defaultproperties, use your attachment class in this line:
                AttachmentClass=

                I had created this as a proof of concept, so I have no problem with anyone using this as is, or modifying it for their purpose.

                Comment


                  #9
                  i get errors


                  Error, Superclass UTattachment_FlakCannon of class UTAttachment_FlakLight not found
                  Error, Superclass UTWeap_FlakCannon of class UTWeap_LightFlak not found
                  Compile aborted due to errors.

                  Warning/Error Summary
                  ---------------------
                  Error, Superclass UTattachment_FlakCannon of class UTAttachment_FlakLight not found
                  Error, Superclass UTWeap_FlakCannon of class UTWeap_LightFlak not found

                  Failure - 2 error(s), 0 warning(s)
                  Execution of commandlet took: 16.18 seconds

                  [COMMANDLET 'UDK.exe make -full' FAILED] december 15, 2:31





                  Analyzing...
                  C:\Users\patric\Desktop\GAME\UDKInstall-2009-11-BETA-2\Development\Src\Unreal_Combat_Stiker\Classes\UTA ttachment_FlakLight.uc(25) : Error, Unknown Function 'ThirdPersonFireEffects' in 'Class UTGame.UTGame'
                  C:\Users\patric\Desktop\GAME\UDKInstall-2009-11-BETA-2\Development\Src\Unreal_Combat_Stiker\Classes\UTA ttachment_FlakLight.uc(17) : Error, 'Mesh': Bad command or expression
                  C:\Users\patric\Desktop\GAME\UDKInstall-2009-11-BETA-2\Development\Src\Unreal_Combat_Stiker\Classes\UTW eap_LightFlak.uc(15) : Error, 'SkeletalMeshComponent': Bad command or expression
                  Compile aborted due to errors.

                  Warning/Error Summary
                  ---------------------
                  C:\Users\patric\Desktop\GAME\UDKInstall-2009-11-BETA-2\Development\Src\Unreal_Combat_Stiker\Classes\UTA ttachment_FlakLight.uc(25) : Error, Unknown Function 'ThirdPersonFireEffects' in 'Class UTGame.UTGame'
                  C:\Users\patric\Desktop\GAME\UDKInstall-2009-11-BETA-2\Development\Src\Unreal_Combat_Stiker\Classes\UTA ttachment_FlakLight.uc(17) : Error, 'Mesh': Bad command or expression
                  C:\Users\patric\Desktop\GAME\UDKInstall-2009-11-BETA-2\Development\Src\Unreal_Combat_Stiker\Classes\UTW eap_LightFlak.uc(15) : Error, 'SkeletalMeshComponent': Bad command or expression

                  Failure - 3 error(s), 0 warning(s)
                  Execution of commandlet took: 4.03 seconds

                  [COMMANDLET 'UDK.exe make' FAILED] december 15, 2:36

                  Comment


                    #10
                    The errors aren't exactly hard to understand. There is no flak cannon in UDK. The real question is, does it work online (i.e, is the light position replicated) ?

                    Comment


                      #11
                      Originally posted by ambershee View Post
                      The real question is, does it work online (i.e, is the light position replicated) ?
                      That's a good question, to which I don't know the answer

                      And I've edited my post to say it was created in UT3.

                      Comment

                      Working...
                      X