Compartilhe

terça-feira, 18 de janeiro de 2011

Unreal Script - Advanced Lighting (continued)

The few niggles with the old system finally got to, and wore me down. After spending a bit of time on a few improvements, I now have lights with a persistent state, so you can leave your light on and switch weapons without artifacts being left behind – and it’s really dead simple.

Two lines in the code are identical:

bLightEnabled = false;

These two lines need to be deleted, and the following block added:

simulated state WeaponPuttingDown
{
simulated function BeginState( Name PreviousStateName )
{
local UTPlayerController PC;

PC = UTPlayerController(Instigator.Controller);
if (PC != None && LocalPlayer(PC.Player) != none )
{
PC.EndZoom();
}
Flashlight.Destroy();
TimeWeaponPutDown();
bWeaponPutDown = false;
}

simulated function EndState(Name NextStateName)
{
Super.EndState(NextStateName);
if (SkeletalMeshComponent(Mesh) == none || WeaponEquipAnim == '')
{
Mesh.SetRotation(Default.Mesh.Rotation);
}
}

simulated function Activate();

/**
* @returns false if the weapon isn't ready to be fired. For example, if it's in the Inactive/WeaponPuttingDown states.
*/
simulated function bool bReadyToFire()
{
return false;
}
}

During the development, there was a slight issue where the light wouldn’t turn on until you had switched away, and then back to your weapon – This was a simple matter of the Flashlight object not being spawned, and the addFlashlight function has been modified accordingly:

simulated function addFlashlight()
{
if(bLight)
{
PlayWeaponAnimation('reload', 1.0);
WorldInfo.Game.Broadcast(self, "Light removed");
Flashlight.Destroy();
bLight = false;
}
else
{
PlayWeaponAnimation('reload', 1.0);
WorldInfo.Game.Broadcast(self, "Light added");
Flashlight = Spawn(class'ZO_WATT_Light', self);
Flashlight.SetBase(self);
Flashlight.LightComponent.SetEnabled(bLightEnabled);
bLight = true;
}
}

I managed to surprise myself at how simple this was after walking away from it for a little bit and coming back with a set of fresh eyes.

This entry was posted in Uncategorized. Bookmark the permalink.

0 comentários:

Postar um comentário

Seu comentário é importante para a manutenção do BLOG.

Não será publicado comentários que infringirem as seguintes regras:

01- ofensas gratuitas aos membros da UDKBrasil
02- descrédito para com a postagem
03- links com malwares ou qualquer tipo de fraude
04- palavras de baixo calão contra participantes
05- links de download não serão permitidos, a não ser que sejam gratuitos (freeware ou software de teste) e relacionados a UDK ou Computação Grafica.

Pedimos a gentileza de não USAR CAPS LOCK ligado.

OBS; assim que seu comentário for publicado,se junto dele NÃO houver uma resposta para sua dúvida,é porque não sabemos te responder...infelizmente, não sabemos de tudo!!

Seja bem vindo.

Fórum UDKBrasil

Top View Semanal

Top View Mensal

Top View de todos os Tempos

 
UDK BRASIL | by TNB ©2010