View Full Version : Unable to hide weapon´s mesh.
mrseth
02-22-2012, 09:38 AM
This is my weapon:
simulated function TimeWeaponEquipping()
{
AttachWeaponTo( Instigator.Mesh,'WeaponPoint' );
super.TimeWeaponEquipping();
}
simulated function AttachWeaponTo( SkeletalMeshComponent MeshCpnt, optional Name SocketName )
{
MeshCpnt.AttachComponentToSocket(Mesh,SocketName);
}
function hide (bool hide)
{
Mesh.SetHidden(hide);
SetHidden(hide);
}
DefaultProperties
{
Begin Object Class=AnimNodeSequence Name=MeshSequenceA
End Object
Begin Object name=FirstPersonMesh
DepthPriorityGroup=SDPG_World
SkeletalMesh=SkeletalMesh'MyWeapons.MySword'
AnimSets(0)=AnimSet'MyWeapons.Mesh_006'
Animations=MeshSequenceA
Translation=(x=-10,y=15,z=20)
CollideActors=false
AlwaysLoadOnClient=true
AlwaysLoadOnServer=true
bUpdateSkelWhenNotRendered=false
bIgnoreControllersWhenNotRendered=true
bOverrideAttachmentOwnerVisibility=true
bAcceptsDynamicDecals=FALSE
Rotation=(Pitch=5000,Yaw=0,Roll=4000)
End Object
begin object name=PickupMesh
SkeletalMesh=SkeletalMesh'MyWeapons.MySword'
Translation=(x=0,y=0,z=20)
Scale =1.5
end object
}
But im unable to make its mesh invisible. I tried SetHidden, Mesh.setHidden but no sucess. Why?
gegebel
02-22-2012, 09:44 AM
shouldn't you do: SetHidden(true) ? since it's a bool
_h2o_
02-22-2012, 09:47 AM
try to reattach weapon mesh after you hide it
mrseth
02-22-2012, 09:49 AM
(bool hide)
Also, put true on both
function hide (bool hide)
{
Mesh.SetHidden(true);
SetHidden(true);
}
just to check and it still didnt worked. The methods aint producing any results.
mrseth
02-22-2012, 09:58 AM
try to reattach weapon mesh after you hide it
still nothing
var MyPawn pawn;
simulated function TimeWeaponEquipping()
{
AttachWeaponTo( Instigator.Mesh,'WeaponPoint' );
pawn = MyPawn(Instigator);
super.TimeWeaponEquipping();
}
simulated function AttachWeaponTo( SkeletalMeshComponent MeshCpnt, optional Name SocketName )
{
MeshCpnt.AttachComponentToSocket(Mesh,SocketName);
}
function hide (bool hide)
{
Mesh.SetHidden(hide);
SetHidden(hide);
if(pawn != none)
{
AttachWeaponTo( pawn.Mesh,'WeaponPoint' );
}
}
IrishKilter
02-22-2012, 10:03 AM
What Function is calling your Hide() function? What's telling it to even run the function?
mrseth
02-22-2012, 10:11 AM
What Function is calling your Hide() function? What's telling it to even run the function?
My custom pawn. The function is being called, I put a `log inside of it and printed what it should print.
edit: im subclassing from UDKGame, UDKPlayerController, UTPawn, GamePlayerCamera, GameCameraBase and UTWeapon if its of any help.
_h2o_
02-22-2012, 10:26 AM
to reattach, first you need to detach it)
hide mesh
detach mesh
attach mesh
mrseth
02-22-2012, 10:30 AM
to reattach, first you need to detach it)
hide mesh
detach mesh
attach mesh
if(pawn != none)
{
DetachWeapon();
AttachWeaponTo( pawn.Mesh,'WeaponPoint' );
}
Still nothing.
_h2o_
02-22-2012, 10:33 AM
what code in DetachWeapon() ?
mrseth
02-22-2012, 10:35 AM
what code in DetachWeapon() ?
From UTWeapon:
simulated function DetachWeapon()
{
local UTPawn P;
DetachComponent( Mesh );
if (OverlayMesh != None)
{
DetachComponent(OverlayMesh);
}
SetSkin(None);
P = UTPawn(Instigator);
if (P != None)
{
if (Role == ROLE_Authority && P.CurrentWeaponAttachmentClass == AttachmentClass)
{
P.CurrentWeaponAttachmentClass = None;
if (Instigator.IsLocallyControlled())
{
P.WeaponAttachmentChanged();
}
}
}
SetBase(None);
SetHidden(True);
DetachMuzzleFlash();
Mesh.SetLightEnvironment(None);
}
_h2o_
02-22-2012, 10:41 AM
so, when you do detach it hides your weapon.. maybe it is enought?
strange why hide+detouch+attach did no work.. maybe then just set weapon material to none or to some transparent material
what do you plan to do after you hide weapon?
mrseth
02-22-2012, 10:43 AM
Nothing. It will remain hidden until I ask to unhide. My third person camera hides the pawn when the camera is about to enter inside its mesh, so I want to keep the weapon hidden too.
_h2o_
02-22-2012, 10:46 AM
then just detach it to hide, and attach to show
mrseth
02-22-2012, 10:48 AM
then just detach it to hide, and attach to show
function hide (bool hide)
{
if(pawn != none)
{
if(hide)
{
DetachWeapon();
`log("hide");
}
else
{
`log("show");
AttachWeaponTo( pawn.Mesh,'WeaponPoint' );
}
}
}
Nothing.
_h2o_
02-22-2012, 10:53 AM
it does not possible, then you doing something wrong, check it, maybe you are trying to hide some other weapon
mrseth
02-22-2012, 11:03 AM
it does not possible, then you doing something wrong, check it, maybe you are trying to hide some other weapon
My pawn only has one weapon and im calling it with
function Hidden(bool hide)
{
Mesh.SetHidden(hide);
MySword(Weapon).hide(hide);
}
mrseth
02-22-2012, 02:14 PM
Ok, fixed but I have NO IDEA WHY.
Wheres the new code.
The weapon
class MySword extends UTWeapon;
simulated function SetPosition(UDKPawn Holder)
{
local Vector socketPosition;
local Rotator socketRotation;
super.SetPosition(Holder);
Holder.mesh.GetSocketWorldLocationAndRotation('Wea ponPoint',socketPosition,socketRotation,0);
SetLocation(socketPosition);
SetRotation(socketRotation);
}
DefaultProperties
{
Begin Object Class=AnimNodeSequence Name=MeshSequenceA
End Object
Begin Object name=FirstPersonMesh
DepthPriorityGroup=SDPG_World
SkeletalMesh=SkeletalMesh'MyWeapons.MySword'
AnimSets(0)=AnimSet'MyWeapons.Mesh_006'
Animations=MeshSequenceA
CollideActors=false
AlwaysLoadOnClient=true
AlwaysLoadOnServer=true
bUpdateSkelWhenNotRendered=false
bIgnoreControllersWhenNotRendered=true
bOverrideAttachmentOwnerVisibility=true
bAcceptsDynamicDecals=FALSE
Rotation=(Pitch=5000,Yaw=0,Roll=4000)
Translation=(x=0,y=10,z=10)
End Object
begin object name=PickupMesh
SkeletalMesh=SkeletalMesh'MyWeapons.MySword'
Translation=(x=0,y=0,z=20)
Scale =1.5
end object
AttachmentClass=class'MySwordAttachment'
WeaponFireTypes(0)=EWFT_InstantHit
WeaponFireTypes(1)=EWFT_None
InstantHitDamage(0)=50
ShotCost(0)=0
AmmoCount=1
MaxAmmoCount=1
WeaponFireAnim(0)=sword
MuzzleFlashSocket=MF
WeaponRange=50
}
the attachment, i dont know why its needed, but if i dont have one, the model will go black, but if i dont put a first person model, the sword wont appear at all.
class MySwordAttachment extends UTWeaponAttachment;
DefaultProperties
{
Begin Object Name=SkeletalMeshComponent0
SkeletalMesh=SkeletalMesh'MyWeapons.MySword'
end object
WeaponClass=class'MySword'
MuzzleFlashSocket=MF
}
VendorX
02-22-2012, 06:18 PM
i dont know why its needed...
Because UT have different approach than UDK and is hard coded.
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.