- Home /
Trying to open a door so far then stop
Trying to open a door from closed to 90 degrees open and then stop.
I can rotate the object but it keeps going around in 360, I need it to stop.
Have below but just gives errors and Im not sure where I am going wrong.
using UnityEngine; using System.Collections;
public class opendoor : MonoBehaviour {
public int rotatespeed=40;
public float i=0;
Vector3 objpos = new Vector3 (0,i,0);
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if(objpos >= Vector3(0,-90,0))
{
transform.Rotate (Vector3.down * Time.deltaTime * rotatespeed);
i+=1;
}
else {
}
}
}
Answer by Bunnybomb7670 · Feb 02, 2014 at 01:23 PM
You could possibly make use of the animation system instead of programming it, you can then just play the animation whenever it is needed, instead of coding it yourself, its a lot easier.
Your answer
Follow this Question
Related Questions
About door opening with mousemovement! 5 Answers
Activate object with key 1 Answer
Open/Close Door Animation disables collider 1 Answer
Open/close door, lags if I walk into it. 0 Answers
Help with making his work with a key 1 Answer