Unreal 多人在线更新collision profile

在线游戏时,SetCollisionProfileName,client和server都要执行

// SERVER
if (character->GetLocalRole() == ROLE_Authority)
	{
		character->GetCapsuleComponent()->SetCollisionProfileName(FName("PawnInCar"), true);
	}
	else
	{
		// 本地client
		if (character->IsLocallyControlled())
		{
			character->GetCapsuleComponent()->SetCollisionProfileName(FName("PawnInCar"), true);
		}
		// 其他client
		else
		{
			character->GetCapsuleComponent()->SetCollisionProfileName(FName("PawnInCar"), true);
			

		}
	}

或者直接写,不要写进Role的判断里就可以了

character->GetCapsuleComponent()->SetCollisionProfileName(FName("PawnInCar"), true);

你可能感兴趣的:(问题,unreal,engine,unreal4,unreal,游戏)