Download

Actor.SetLocation not working in NM_Client?

Basically, I’ve got a function that teleports a player to a random path node in a level.


exec function Teleport(Actor Other)
{

local PathNode D;
local Array <PathNode> Dest;
local int i;
local vector PathVector;


	//Adds all Pathnodes in the Level to the Array
	//BETA - FOR TESTING ONLY!! Level Designers, do not place PathNodes in places you do not want a player to Spawn!
	//This will be corrected with the creation of a TeleportNode Actor in the final game.
	foreach AllActors (Class 'PathNode', D)
	{
		Dest.AddItem(D);
	}


	//Randomly select an Available PathNode
	i = Rand (Dest.Length);
	

	//If there are pathnodes in the Array..
	if( Dest* != None )
	{
		PathVector = Dest*.Location;
	// Teleport the actor to the Random PathNode
		if ( Other.IsA('Pawn') )
		{
			Other.SetLocation(PathVector);
		}
	}
	//If no PathNodes available (How?!), Log an Alert
	else 
		`log ("No PathNodes Available!");
}

I know It’s a bit of a hack (I need to make a new object to use as the teleportation point instead of using pathnodes), but it’s working fine in NM_Standalone, so the code is sound.

The problem is coming up during multiplayer testing, where when the function is triggered in NM_Client, the player is siccesfully teleported, but only for one or two frames (depending on server lag) before being placed back in the previous position.
Seems that the server is maybe detecting it as a cheat or something, or the function isn’t replicated properly?

Any help? This is literally the last thing I need to fix before i’m done with my college coding unit :slight_smile:

Nevermind, got it!

the function needed to be a reliable server function, and then get called by the client. :slight_smile:

so it literally got fixed by replacing “exec” with “reliable server”. :slight_smile:

Whoot!

Thanks for sharing your solution :slight_smile: