anyone have a esay to use script for opening and closeing doors without haveing animation or can u even do that thanks for any help i dont know anything about Scripting is there any good books i could buy so i can learn thx
I don’t have a script handy but doing it via code should be trivial, it’s likely best for you to get your feet wet already as you’re gonna need to do some scripting at some point.
Look at Transform and in particular the Rotate method. It will allow you to rotate an object via code (like rotating a door on its hinges).
I have a simple one at home, can’t remember it off the top of my head. Basically you make a cube in the editor and size it to your doorway.
Then you put a hinge joint on it, set the anchor and the pivot.
I think the script to open it was something like:
var parent : Transform;
var hit : RaycastHit;
function Update () {
if (Input.GetKey ("e") Physics.Raycast(Camera.main.ViewportPointToRay(Vector3(0.5, 0.5, 0.0)), hit,5) )
}
I’ll check tonight,I can’t remember the rest of it. I stuck the script on the player and it works for me.
It kind of swings back and forth, it’s not perfect, but it’s a start.
If you just put the door on a hinge you can walk into it and it’ll swing foward on its own.
Of course, this really depends on the type of door you want. Sci-Fi sliding doors open differently than medieval ones, rotating doors, western saloon entrances, etc…
Each door is very unique. The question is, what do you want the door to do?
thanks for posts i think i need 2 buy a book about Scripting as i never did it b4 bein useing 3d max for a wile so making models be np thx again