News UnrealEd Files Mods FragBU Liandri Archives
BeyondUnreal Forums

Go Back   BeyondUnreal Forums > Unreal Development > Coding

Reply
 
Thread Tools Display Modes
Old 2nd Feb 2010, 04:42 AM   #1
Shadow_knight
Carpe diem!
 
Shadow_knight's Avatar
 
Join Date: Jan. 29th, 2008
Location: Prague
Posts: 48
Switch player skin in UE2

Hi!

I am playing with UnrealRuntime 2 - what I want to do now is to switch player skin dynamicly (to simulate smiling or angry face by changing the texture), but it seems impossible to change the texture... I am quite suprised the code below doesn't work.
The pawn inits with default texture - no problem there, when I call both ServerChangeTexture() and ChangeTexture() the texture actually changes but to blank texture. I am doing this in network game.

Even when I use DynamicLoadObject instead of helper variable MyHappyTex in PostNetReceive() I get the blank texture result. Am I missing something ? Or do these things work differently in Unreal Runtime 2?

Code:
class GBPawn extends Pawn;

#exec OBJ LOAD FILE=_PGTX-EmoBoy.utx

var texture MyTexture[2];

var texture MyHappyTex[2];

replication
{
	reliable if(Role == Role_Authority)
		MyTexture, MyHappyTex;  
}

simulated event PostBeginPlay()
{
	Super.PostBeginPlay();

	// if this pawn is supposed to cast dynamic shadows
	if(bActorShadows && bPlayerShadows)
	{
		// Spawn the shadow and intialize it
		Shadow = Spawn(class'ShadowProjector',None,'',Location);
		Shadow.ShadowActor = self;
		Shadow.LightDirection = Normal(vect(1,1,3));
		Shadow.LightDistance = 380;
		Shadow.MaxTraceDistance = 3000;
		Shadow.bBlobShadow = bBlobShadow;
		Shadow.InitShadow();
		Shadow.UpdateShadow();
	}

	MyHappyTex[0]=Texture(DynamicLoadObject("_PGTX-Emoboy.emoboy_clothes_01", class'Texture'));
	MyHappyTex[1]=Texture(DynamicLoadObject("_PGTX-Emoboy.emoboy_skin", class'Texture'));
}

function ServerChangeTexture() {
	MyTexture[0]=MyHappyTex[0];
	MyTexture[1]=MyHappyTex[1];

	//MyTexture[0]=Texture(DynamicLoadObject("_PGTX-Emoboy.emoboy_clothes_01", class'Texture'));
	//MyTexture[1]=Texture(DynamicLoadObject("_PGTX-Emoboy.emoboy_skin", class'Texture'));
}

simulated function changeTexture() {
	MyTexture[0]=MyHappyTex[0];
	MyTexture[1]=MyHappyTex[1];

	//MyTexture[0]=Texture(DynamicLoadObject("_PGTX-Emoboy.emoboy_clothes_01", class'Texture'));
	//MyTexture[1]=Texture(DynamicLoadObject("_PGTX-Emoboy.emoboy_skin", class'Texture'));
}


simulated function PostNetReceive() {
	//if (MyTexture[0] != none && Skins[0].Name != MyTexture[0].Name)
	//if (MyTexture[1] != none && Skins[1].Name != MyTexture[1].Name)

	Skins[0]=MyTexture[0];
	Skins[1]=MyTexture[1];
}

defaultproperties
{
	MyTexture(0)=Texture'CivilTex.cloth'
	MyTexture(1)=Texture'CivilTex.Skin'
	MyHappyTex(0)=Texture'_PGTX-Emoboy.emoboy_clothes_01'
	MyHappyTex(1)=Texture'_PGTX-Emoboy.emoboy_skin'
	bActorShadows=true
	bPlayerShadows=true
	bNetNotify=true
}
Shadow_knight is offline   Reply With Quote
Old 5th Mar 2010, 10:54 AM   #2
Shadow_knight
Carpe diem!
 
Shadow_knight's Avatar
 
Join Date: Jan. 29th, 2008
Location: Prague
Posts: 48
After some digging and trying I have a solution!

It seems there is some problem with replication with more complex objects - textures etc. The code I posted did not work, however, if I replicate an int value and I change the texture according to this value everything works fine. Working code below. Just call changeTexture function with appropriate argument and everything will work.

Code:
class PogamutMale extends GBPawn
	config(GBEmohawk);

var Texture	MyTextureOne;
var Texture	MyTextureTwo;
var Texture	MyHappyTexOne;
var texture	        MyHappyTexTwo;

var int repInt;

replication
{
	reliable if(Role == Role_Authority)
		repInt, MyTextureOne, MyTextureTwo, MyHappyTexOne, MyHappyTexTwo;
}


simulated event PostBeginPlay()
{
	Super.PostBeginPlay();

	LinkMesh(Mesh(DynamicLoadObject("_PGA-EmoboySized.emoboy_mesh", class'Mesh')),false);

	Skins[0]=Texture(DynamicLoadObject("_PGTX-Emoboy.emoboy_skin", class'Texture'));
	Skins[1]=Texture(DynamicLoadObject("_PGTX-Emoboy.emoboy_clothes_01", class'Texture'));

	MyHappyTexOne=Texture(DynamicLoadObject("_PGTX-Emoboy.emoboy_skin", class'Texture'));

	MyHappyTexTwo=Texture(DynamicLoadObject("_PGTX-Emoboy.emoboy_clothes_01", class'Texture'));

	MyTextureOne=Texture(DynamicLoadObject("CivilTex.cloth", class'Texture'));
	MyTextureTwo=Texture(DynamicLoadObject("CivilTex.Skin", class'Texture'));
}

simulated function ChangeTexture(int i) {
     repInt = i;
}

simulated event PostNetReceive() {
	if (repInt == 1) {
		Skins[0] = MyTextureOne;
		Skins[1] = MyTextureTwo;
		repInt = 0;
	} else if (repInt == 2) {
		Skins[0]=MyTexture[0];
		Skins[1]=MyTexture[1];
                repInt = 0;

       }
}

defaultproperties
{
	MyTextureOne=Texture'CivilTex.cloth'
	MyTextureTwo=Texture'CivilTex.Skin'
	MyHappyTexOne=Texture'_PGTX-Emoboy.emoboy_skin'
	MyHappyTexTwo=Texture'_PGTX-Emoboy.emoboy_clothes_01'
	Mesh=SkeletalMesh'_PGA-EmoboySized.emoboy_mesh'
	IdleAnim="stand_normal"
	MovementAnims[0]="run_normal"
	MovementAnims[1]="run_normal"
	MovementAnims[2]="run_normal"
	MovementAnims[3]="run_normal"
	TurnLeftAnim="walk_loop"
	TurnRightAnim="walk_loop"
	bPhysicsAnimUpdate=true
	bCanCrouch=false
	GroundSpeed=440
	Skins(0)=Texture'_PGTX-Emoboy.emoboy_skin'
	Skins(1)=Texture'_PGTX-Emoboy.emoboy_clothes_01'
	bActorShadows=true
	BaseEyeHeight=128
	bNetNotify=true
}
best,
sk
Shadow_knight is offline   Reply With Quote
Reply

Tags
change, player skin, texture

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 12:42 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.

Copyright ©1998 - 2012, BeyondUnreal, Inc.
Privacy Policy | Terms of Use
Bandwidth provided by AtomicGamer