- Home /
How to change characters with pressing a button
Hi, I am making a GTA clone. I want to press E to change from character to car. I know how to change cameras. I tried to edit the camera script and this is what it looks like plus i got errors:
var CameraPlayer1 : Camera;
var CameraPlayer2 : Camera;
var Player1 : GameObject;
var Player2 : GameObject;
function OnTriggerEnter (col : Collider) {
if (isDriving == false) { isDriving = true; GetIn(); } }
function GetIn() {
{
if(Input.GetKeyDown("E")) && ((isDriving) == true)) { isDriving = false; GetOut(); } }
{
Player1.active = true;
Player2.active = false;
CameraPlayer1.active = true;<BR>
CameraPlayer2.active = false;<BR>
<BR>
Player1Script.GetComponent("PlayerCar_Script").enabled = true;<BR>
Player2Script.GetComponent("FPSWalker").enabled = false;<BR>
}
}
function GetOut() {
{
if(Input.GetKeyDown("E"))
{
Player1.active = false;
Player2.active = true;
CameraPlayer1.active = false;
CameraPlayer2.active = true;
Player1Script.GetComponent("PlayerCar_Script").enabled = false;
Player2Script.GetComponent("FPSWalker").enabled = true;
}
}