Hi guys ,
I have test the " enter exit vehicle " on network, (JS code)
I have a probleme with the name of networkplayer. (enter vehicle its good, just for exit)
test code : "GameObject.FindWithTag(“Player”).active=false; "
" GameObject.Find(“NetworkPlayer(Clone)”+ photonView.owner).active=true; "
name is “NetworkPlayer+photon.owner”
var car : Transform;
var player : Transform;
private var Player : GameObject;
var exitPoint : Transform;
var doorTriggerLeft : Transform;
private var PlayerCamera : GameObject;
var CarCamera : Camera;
var isPlayerVisible : boolean;
var Car : GameObject;
//var MainCam : GameObject;
//var WeaponCam : GameObject;
var photonView : String = “PhotonView”;
var CarScript : String = “ScriptName”;
function Start (){
Car.GetComponent(CarScript).enabled=false;
Player = GameObject.FindWithTag("Player");
//player = Transform.FindWithTag("Player");
}
function Update(){
if (Input.GetButtonUp(“Use”)&& isPlayerVisible){
// make player invisible and still standing
// player.gameObject.SetActiveRecursively(false); //player.gameObject.active = false;
// GameObject.FindWithTag(“Player”).active=false;
GameObject.Find(“NetworkPlayer(Clone)”+ photonView.owner).active=true;
// parent player to Exit Point
// player.parent = exitPoint.transform;
player.transform.localPosition = Vector3(-1.5,0,0);
// parent PlayerParent to car
exitPoint.parent = car.transform;
// exitPoint.transform.localPosition = Vector3(-0.5,0,0);
// Enable Car as controllabe object
Car.GetComponent(CarScript).enabled=true;
// MainCam.GetComponent(“Camera”).enabled=false;
// WeaponCam.GetComponent(“Camera”).enabled=false;
CarCamera.enabled = true;
}
else
{
if (Input.GetKeyUp(“r”)){
// make character visible again
// player.gameObject.SetActiveRecursively(true);
// player.gameObject.active = true;
GameObject.Find(“NetworkPlayer(Clone)”+ photonView.owner).active=false;
// unparent player from everything
// player.transform.parent = null;
// parent Exit Point to door Trigger
// exitPoint.parent = doorTriggerLeft.transform;
// disable car as controllable
GameObject.Find(“Car”).GetComponent(“Car”).enabled=false;
// MainCam.GetComponent(“Camera”).enabled=true; //WeaponCam.GetComponent(“Camera”).enabled=true;
CarCamera.enabled = false;
}
}
}
function OnTriggerEnter(Player : Collider) {
isPlayerVisible = true;
}
function OnTriggerExit(Player : Collider) {
isPlayerVisible = false;
}
Thanks for your help.
For any help, please format your code. You can do this by highlighting all your code, then clicking the 10101 button at the top of the edit window. Please don't post comments as answers. Post comments by clicking the [add new comment] button, a window then open for you to type in. Answer fields are for answers only, as this is a knowledge base. Here at Unity Answers, Answer means Solution, not Response. * Read this page : http://answers.unity3d.com/page/newuser.html * Watch : http://video.unity3d.com/video/7720450/tutorials-using-unity-answers
For any help, please format your code. You can do this by highlighting all your code, then clicking the 10101 button at the top of the edit window. Please don't post comments as answers. Post comments by clicking the [add new comment] button, a window then open for you to type in. Answer fields are for answers only, as this is a knowledge base. Here at Unity Answers, Answer means Solution, not Response. * Read this page : http://answers.unity3d.com/page/newuser.html * Watch : http://video.unity3d.com/video/7720450/tutorials-using-unity-answers
– AlucardJay