NetPadBehaviour
Core Properties
Lifecycle Methods
Usage Pattern
Deriving from NetPadBehaviour
public class PlayerController : NetPadBehaviour
{
public override void OnInstantiate()
{
// Custom setup after NetPad instantiation
Debug.Log($"Player {NetPadPlayer.PlayerId} connected");
}
private void Update()
{
if (!IsValid) return;
// Access input directly through NetPadInput
var joystick = NetPadInput.GetJoystick("MovementStick");
if (joystick.Magnitude > 0.1f)
{
transform.Translate(joystick.Position * speed * Time.deltaTime);
}
// Check button input
if (NetPadInput.GetButtonDown("JumpButton"))
{
Jump();
}
}
public override void OnRemove()
{
// Cleanup before player disconnection
SavePlayerData();
}
}Instantiation Requirement
Proper Instantiation
Benefits Over MonoBehaviour
Best Practices
Last updated