- Home /
Door script doesnt work need help
I made this script but I cant get the collider working. will someone please help me here is the script
// Smothly open a door var smooth = 2.0;
var DoorOpenAngle = 90.0;
var DoorCloseAngle = 0.0;
var open : boolean;
var enter : boolean;
//Main function
function Update (){
if(open == true){
var target = Quaternion.Euler (0, DoorOpenAngle, 0);
// Dampen towards the target rotation
transform.localRotation = Quaternion.Slerp(transform.localRotation, target,
Time.deltaTime * smooth);
}
if(open == false){
var target1 = Quaternion.Euler (0, DoorCloseAngle, 0);
// Dampen towards the target rotation
transform.localRotation = Quaternion.Slerp(transform.localRotation, target1, Time.deltaTime * smooth); }
if(enter == true){
if(Input.GetKeyDown("e"))
{
open = !open;
}
}
}
//Activate the Main function when player is near the door
function OnTriggerEnter (other : Collider)
{
if (other.gameObject.tag == "Player")
{
(enter) = true;
} }
//Deactivate the Main function when player is go away from door
function OnTriggerExit (other : Collider)
{
if (other.gameObject.tag == "Player")
{
(enter) = false;
}
}
sorry for bad english
Your answer
![](https://koobas.hobune.stream/wayback/20220613083403im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Door Opens When Not In Trigger And Sound Help 1 Answer
Need help with my animation script 2 Answers
Trap Door Question 1 Answer
Animate Doors and Button Through Script 1 Answer
Animation clip does not exist? 1 Answer