This is my enter and exit script what should i do to make my character play an animation clip while entering and exiting?
My enter button is ‘E’
How can i edit the script to play an animation?
How can i make my character open the car door and sit in it?
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.GetButton("e")&& 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("CarController").enabled=true;
GameObject.Find("Car").GetComponent("CarUserControl").enabled=true;
PlayerCamera.enabled = false;
CarCamera.enabled = true;
}
else
{
if (Input.GetKeyUp("f")){
// 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("CarController").enabled=false;
GameObject.Find("Car").GetComponent("CarUserControl").enabled=false;
PlayerCamera.enabled = true;
CarCamera.enabled = false;
}
}
}
function OnTriggerEnter(Player : Collider) {
isPlayerVisible = true;
}
function OnTriggerExit(Player : Collider) {
isPlayerVisible = false;
}