Quantcast
Channel: Questions in topic: "javascipt"
Viewing all articles
Browse latest Browse all 1875

Noob question: easing slidingdoor animation

$
0
0
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"); } }

Viewing all articles
Browse latest Browse all 1875

Trending Articles



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