by nazakomu » Thu Mar 29, 2018 7:19 pm
This is an interesting topic for me, since recently, I've been working on PSprites and such. As far as I can tell, currently they're somewhat difficult to work with, and that can definitely be my fault for not being adept with ZScript.
The way I'm handling the bobbing and other PSprite work is in an override of Tick() in the PlayerPawn class I have, and it seemingly is the worst place to do it as there is an atrocious bug that comes out of doing it (i.e. when the player moves while entering their death state, the game crashes).
A code example is:
Code: Select all
override void Tick()
{
if (!player || !player.mo || player.mo != self)
{
Super.Tick();
return;
}
// The CheckWeaponSelected function is written elsewhere, but is the exact same function from the status bars. It is used as a check to make sure I can do things with specific weapons, such as changing the speed and intensity.
if (CheckWeaponSelected("Pistol"))
{
let psp = player.GetPSprite(PSP_WEAPON); // I also tried player.FindPSprite, to which was no success.
if (player.onground)
{
// Bobbing gets done here.
}
}
}
The reason the crashing seems to be happening is because of the way I'm accessing the PSprite (let psp = player.GetPSprite(PSP_WEAPON)). It has caused crashing before if just openly put in the Tick() override without any checks, too.
I alternatively, tried transitioning the bobbing itself into the weapon instead, to which didn't work out so well, again probably due to me not being so experienced with it..
Perhaps, I'm really just doing things wrong.
This is an interesting topic for me, since recently, I've been working on PSprites and such. As far as I can tell, currently they're somewhat difficult to work with, and that can definitely be my fault for not being adept with ZScript.
The way I'm handling the bobbing and other PSprite work is in an override of Tick() in the PlayerPawn class I have, and it seemingly is the worst place to do it as there is an atrocious bug that comes out of doing it (i.e. when the player moves while entering their death state, the game crashes).
A code example is:
[code]
override void Tick()
{
if (!player || !player.mo || player.mo != self)
{
Super.Tick();
return;
}
// The CheckWeaponSelected function is written elsewhere, but is the exact same function from the status bars. It is used as a check to make sure I can do things with specific weapons, such as changing the speed and intensity.
if (CheckWeaponSelected("Pistol"))
{
let psp = player.GetPSprite(PSP_WEAPON); // I also tried player.FindPSprite, to which was no success.
if (player.onground)
{
// Bobbing gets done here.
}
}
}
[/code]
The reason the crashing seems to be happening is because of the way I'm accessing the PSprite (let psp = player.GetPSprite(PSP_WEAPON)). It has caused crashing before if just openly put in the Tick() override without any checks, too.
I alternatively, tried transitioning the bobbing itself into the weapon instead, to which didn't work out so well, again probably due to me not being so experienced with it..
Perhaps, I'm really just doing things wrong. :?