- Home /
Enter/Exit vehicle
im a complete noob and i found a script (below)
var car : Transform; var player : Transform; var exitPoint : Transform; var doorTriggerLeft : Transform; var PlayerCamera : Camera; var CarCamera : Camera; var isPlayerVisible : boolean;
function Update(){ if (Input.GetButtonUp("Action")&& isPlayerVisible){ // make player invisible and still standing player.gameObject.SetActiveRecursively(false); player.gameObject.active = false; // 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 GameObject.Find("car").GetComponent("DrivingScript").enabled=true; PlayerCamera.enabled = false; CarCamera.enabled = true; } else { if (Input.GetKeyUp("r")){ // make character visible again player.gameObject.SetActiveRecursively(true); player.gameObject.active = true; // 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("DrivingScript").enabled=false; PlayerCamera.enabled = true; CarCamera.enabled = false;
}
}
}
function OnTriggerEnter(Player : Collider) { isPlayerVisible = true; }
function OnTriggerExit(Player : Collider) { isPlayerVisible = false;
yeahhhhhhh... i have no idea what to do with it such as c# SCRIPT OR javascript and were do i paste it because i keepe getting errors
Please better format your code using the inline code formatter
Usually, such scripts have very specific usages within some very specific setups. In order to re-create these setups you need to really understand how the script works, and as i can see, create multiple prefabs and name them properly. I suggest that you get to create the script yourself, in a way that would suit your setup more. (It's also javascript, by the way)
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
JS Enter Exit with NetworkPlayer 1 Answer
Problem Enter and Exit with Vehicle 2 Answers
How do you make character enter and exit vehicles. 1 Answer
How to turn a tank? 1 Answer