Question by
kostasandre · Jun 08, 2016 at 04:17 PM ·
c#scripting problemdoors
Cant make Door Open
Hello everyone i have followed many tutorials about a simple door opening script but i cant figure it out.So what ive donw is make an empty game object and parent it to the door.My script is this :
using UnityEngine;
using System.Collections;
public class DoorOpen : MonoBehaviour
{
public bool IsOpen = false;
public float DoorOpenAngle = 90f;
public float DoorCloseAngle = 0f;
public float Smooth = 2f;
void Start()
{
}
public void ChangeDoorState()
{
IsOpen = !IsOpen;
}
void update()
{
if (IsOpen)
{
Quaternion TargetRotationOpen = Quaternion.Euler(0, DoorOpenAngle, 0);
transform.localRotation = Quaternion.Slerp(transform.localRotation, TargetRotationOpen, Smooth * Time.deltaTime);
}
else
{
Quaternion TargetRotationOpen = Quaternion.Euler(0, DoorCloseAngle, 0);
transform.localRotation = Quaternion.Slerp(transform.localRotation, TargetRotationOpen, Smooth * Time.deltaTime);
}
}
}
In order to test it i simply move mi script to door inspector i hit play then pause and set the bool to true but the door doesnt open...What do i miss??
screenshot-8.png
(336.0 kB)
Comment
Answer by e4lime · Jun 09, 2016 at 05:04 AM
Change void update()
to void Update()
.
:)
O my God...im a total noob..!!! and blind.. :P Thanks man i was searching alla the google,,... :P so foolish i am...