Alright I got a very basic door set up that changes color when you click on it (just to see when the door is active). Next thing i wanna do is make the door rotate when i drag the mouse, so for example if i drag the mouse down it rotates towards the player while if you drag the mouse up it rotates away from the player.
How can I do this?
using UnityEngine;
using System.Collections;
public class DoorScript: MonoBehaviour {
void OnMouseDown() {
renderer.material.color = Color.red;
audio.Play();
}
void OnMouseUp() {
renderer.material.color = Color.blue;
}
}
maybe some parts should be fixed, I have used something like that what you need
but problem is what doors will spin around their pivot point, so you’ll have to use Transform.RotateAround if you don’t have pivot fixed if it is rotating too fast or slow, just play with “a” variable.
this is my own code that I’ve wrote without anyone so maybe there is better way to do it,
thing how it works is it checks mouse position, and then after 1 update it checks 2nd position and it uses difference between that two vectors