logo
Main

Forums

Downloads

Unreal-Netiquette

Donate for Oldunreal:
Donate

borderline

Links to our wiki:
Wiki

Walkthrough

Links

Tutorials

Unreal Reference

Usermaps

borderline

Contact us:
Submit News
Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic RenderOverlays() question (Read 73 times)
Rocky
Junior Member
**
Offline


Oldunreal member

Posts: 74
Location: (X) Unable To Locate....
Joined: Nov 18th, 2013
Gender: Male
RenderOverlays() question
May 17th, 2017 at 2:59pm
Print Post  
I am trying to port UT3 weapons to 227.

So in UT3, the weapons and arms are both separate meshes and I can't find way to merge them in any model editors.

Hence, I had to add them seperately (coding way). So my question is how to add the "Arms" in RenderOverlays() function properly??

Here is code:
Code
Select All
var(RenderOverlays) WP_SniperRifleArms Arms;
var mesh ArmsMesh;
var int NumFire;

replication
{
	reliable if(Role == ROLE_Authority)
		Arms;
}

simulated function PostBeginPlay()
{
	PrepareArms();
	Super.PostBeginPlay();
}

simulated event RenderOverlays(Canvas Canvas)
{
	Super.RenderOverlays(Canvas);

	//PrepareArms();

	if(Arms != None)
	{
		Arms.Style = STY_Normal;
		Arms.bUnlit = false;
		Arms.bMeshEnviroMap = False;
		Arms.Texture = None;
		Arms.Mesh = ArmsMesh;
		Arms.SetLocation(Location);
		Arms.SetRotation(Pawn(Owner).ViewRotation);
		Canvas.DrawActor(Arms, False, False);
	}
	else if(ArmsMesh != None)
	{
		Arms = Spawn(Class'WP_SniperRifleArms', Self);
		Arms.Mesh = ArmsMesh;
		Arms.DrawScale = PlayerViewScale;
		Arms.bHidden = true;
	}
}

simulated function PrepareArms()
{
	if(Pawn(Owner) == None)
		return;

	if(Arms == None)
	{
		Arms = Spawn(Class'WP_SniperRifleArms', Self);
		Arms.DrawScale = PlayerViewScale;
		Arms.bHidden = true;
	}
	else
		return;
} 



This partially works. Like if I select the Sniper Rifle for first time, the arms mesh doesn't show up. However when I select again, it shows up.

Here is WP_SniperRifle.UC:
Code
Select All
class WP_SniperRifleArms extends Effects;

simulated function Tick(float Delta)
{
	/*if (Owner != None && bHidden != Owner.bHidden)
	{
		bHidden = Owner.bHidden;
		bOldHidden = bHidden;
	}
	else*/
	if (Owner == None)
		Destroy();
}

defaultproperties
{
    bHidden=True
    bAnimByOwner=True
    bNetTemporary=False
    DrawType=DT_Mesh
    Mesh=LodMesh'UnrealShare.WoodenBoxM'
    Mass=0.000000
} 



Another problem is, the arms doesn't animate along with owner i.e. the Sniper Rifle even though the property bAnimByOwner is set to true.

To animate I have to seperately write like this:
Code
Select All
Arms.PlayAnim('Select', 1.0, 0.04); //Same for fire, idle and down animations 



Can anyone help me on how to spawn the arms and animate along with gun??
Thanks.
  
Back to top
 
IP Logged
 
.:..:
Oldunreal MasterPoster
Developer Team
*
Offline



Posts: 1403
Location: Finland
Joined: Aug 16th, 2005
Gender: Male
Re: RenderOverlays() question
Reply #1 - May 17th, 2017 at 3:23pm
Print Post  
Try something along this:
Code
Select All
var WP_SniperRifleArms Arms;
var(RenderOverlays) mesh ArmsMesh;
var int NumFire;

simulated event RenderOverlays(Canvas Canvas)
{
	Super.RenderOverlays(Canvas);

	if(ArmsMesh != None)
	{
		if( Arms==None )
			PrepareArms();

		Arms.DrawScale = DrawScale;
		Arms.Style = Style;
		Arms.bUnlit = bUnlit;
		Arms.Texture = Texture;
		Arms.bMeshEnviroMap = bMeshEnviroMap;
		Arms.AnimSequence = AnimSequence;
		Arms.AnimFrame = AnimFrame;
		Arms.bAnimLoop = bAnimLoop;
		Arms.SetLocation(Location);
		Arms.SetRotation(Rotation);
		Canvas.DrawActor(Arms, False, False);
	}
}

simulated function PrepareArms()
{
	Arms = Spawn(Class'WP_SniperRifleArms', Self);
	Arms.Mesh = ArmsMesh;
}

simulated function Destroyed()
{
	Super.Destroyed();
	if( Arms!=None )
		Arms.Destroy();
} 



Code
Select All
class WP_SniperRifleArms extends Effects
	transient;

defaultproperties
{
	bHidden=True
	DrawType=DT_Mesh
	Mass=0.000000
	RemoteRole=ROLE_None
} 

  

Shivaxi wrote on Jul 25th, 2013 at 12:50pm:
...and now im stuck trying to fix everything you broke for the next 227 release xD Tongue

(ಠ_ಠ)
Back to top
ICQYIM  
IP Logged
 
Rocky
Junior Member
**
Offline


Oldunreal member

Posts: 74
Location: (X) Unable To Locate....
Joined: Nov 18th, 2013
Gender: Male
Re: RenderOverlays() question
Reply #2 - May 18th, 2017 at 6:31am
Print Post  
Thank you very much. That works!  Smiley
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint
Bookmarks: del.icio.us Digg Facebook Google Google+ Linked in reddit StumbleUpon Twitter Yahoo