Noob question: easing slidingdoor animation

I’m completely new to unity, been working in it for 10 weeks now. I want to make a sliding door, but I don’t know how. I’ve got a script that makes it move instantly, is it possible to ad an easing function in this script, or do I have to rescript it some other way?

var enter : boolean; 
var open : boolean;

	function Start (){
		
	}
    
	
	function Update ( ){
		var deur = GameObject.FindWithTag("BodySchuifdeur");
		
	 if(open == true){ 
		deur.transform.localPosition = Vector3(-3.3, -0.65, 0);
      }
     
    if(open == false){
		deur.transform.localPosition = Vector3(0, -0.65, 0);
      }
     
       if(enter == true){
         if(Input.GetKeyDown("f")){
      open = !open;
         }
      }

	}


	//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;
      }
	 }

function OnGUI(){
		if(enter){
		GUI.Label(new Rect(Screen.width/2 - 80, Screen.height - 100, 250, 30), "PRESS F to open/close the door");
		}
     }

Is actually too smooth,a bit delayed,it is not crisp.

2 Answers

2

Unity 3d Sliding Door - Vylaxez - YouTube this is a video were I explain what to do with my script and here’s the script : Unity 3d JS Sliding Door - Pastebin.com

so now set the answer as best and close the subject I enjoy to see it's helpfull

It creates aiming issues,as is not that crisp.

Try disabling vsync in Edit > Project Settings > Quality if you have it enabled, it could make a bit of difference.

@ThePixelGamers - I’m using that script you posted for a normal openable door (with rotation), I’m looking for a sliding door, that just slides to the side. Thanks for the idea but that’s not what I’m looking for. The door just needs to slide along the X-axis smoothly when activated with the F key.

Most preferably I’d like to make this happen: when you approach, the GUI indicator to press F is activated, when pressed the door slides open smoothly and automatically slides back after like 10 seconds. If that’s too much trouble, then I need just the easing part, make it animate instead of instantly moving to the new position which happens in my current script.

Ok, I gona make you a sliding (on X axis) door. You will at least got it this week-end (sorry for my bad english)

I'm creating a crouch script (so Y axis) so I gonna trasnlate it in X axis

https://youtu.be/rOQrVyeeUI8 this is a video were I explain what to do with my script and here's the script : http://pastebin.com/RWqPxZ5T

I use the default script..and I use it on a character controller and camera..just like in a fresh project.