UE1 - UT Accessed Non in Touch()

  • Two Factor Authentication is now available on BeyondUnreal Forums. To configure it, visit your Profile and look for the "Two Step Verification" option on the left side. We can send codes via email (may be slower) or you can set up any TOTP Authenticator app on your phone (Authy, Google Authenticator, etc) to deliver codes. It is highly recommended that you configure this to keep your account safe.

Rajada

Member
Jan 21, 2008
213
0
16
rajada.tumblr.com
Getting an accessed none in this function.

Code:
function Touch( actor Other )
{
	if (
        Other.IsA('Pawn')
        && !PlayerPawn(other).IsInState('CheatFlying') 
			&& other.Physics!=PHYS_Swimming &&
       ( (LimitedToName ==  '')
       ||(Other.IsA(LimitedToName)) )
       )
	{
		Pending = Pawn(Other);
		SetTimer(0.01, false);
		if ( bOnceOnly )
			Disable('Touch');
	}
}

Am I missing a stupid mistake? What could possibly be the none here?
 

gopostal

Active Member
Jan 19, 2006
848
47
28
Add a wrapper to your code to check for bad conditions:

Code:
function Touch( actor Other )
{
	if (Other !=none)
        {

Touch can error because you may be touching the actor as it destroys or moves away from touch. If you code is running at the very moment then you could get a return of =none.

Wide swaths of access nones are cleared by adding the right
Code:
if(actor !=none)
checks.
 
Last edited:

meowcat

take a chance
Jun 7, 2001
803
3
18
I think the problem is you check to see if it is pawn, and then assume it is a playerpawn in the next check (see highlighted check below) in which the cast could fail (resulting in trying to check IsInstate on a null reference)
Code:
if (
        Other.IsA('Pawn') && ![COLOR="Blue"]PlayerPawn[/COLOR](other).IsInState('CheatFlying') 
            && other.Physics!=PHYS_Swimming
            &&  ( (LimitedToName ==  '') || (Other.IsA(LimitedToName)) )
    )

Since the IsInState function should work for any actor you could probably just leave it at !Other.IsInState('CheatFlying')