Quantcast
Channel: Questions in topic: "issue"
Viewing all articles
Browse latest Browse all 827

Player and door collision issue

$
0
0
I have a script from [youtube][1] that would simply open and close the door using the 'F' key. // Smothly open a door var smooth = 2.0; var DoorOpenAngle = 90.0; private var open : boolean; private var enter : boolean; private var defaultRot : Vector3; private var openRot : Vector3; function Start(){ defaultRot = transform.eulerAngles; openRot = new Vector3 (defaultRot.x, defaultRot.y + DoorOpenAngle, defaultRot.z); } //Main function function Update (){ if(open){ //Open door transform.eulerAngles = Vector3.Slerp(transform.eulerAngles, openRot, Time.deltaTime * smooth); }else{ //Close door transform.eulerAngles = Vector3.Slerp(transform.eulerAngles, defaultRot, Time.deltaTime * smooth); } if(Input.GetKeyDown("f") && enter){ open = !open; } } function OnGUI(){ if(enter){ GUI.Label(new Rect(Screen.width/2 - 75, Screen.height - 100, 150, 30), "Press 'F'"); } } //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; } } the problem is that everytime I open/close the door, it passes through the character but when I assign a rigid body to the door, everything works just fine except for the door getting removed from the pivot. :( [Collision Issue.zip][1] [1]: http://www.mediafire.com/download/3c2qvnr7ckfb988/Collision_Issue.zip I even tried to add a hinge joint component but it just keeps jittering everytime I press the 'F' key. Any idea ?

Viewing all articles
Browse latest Browse all 827


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>