Jump to content
Unity Insider Forum

q3max

Members
  • Content count

    2
  • Joined

  • Last visited

Community Reputation

0 Neutral

About q3max

  • Rank
    Newbie
  1. Hi, Eventsystem vergessen?
  2. q3max

    Spielergesteuerte rotierende Tür

    using UnityEngine; using System.Collections; public class theDoor : MonoBehaviour { public Transform door; public Vector3 doorAngle; public Transform player; bool toPlayer; void Start () { } bool open = false; void Update () { if(Input.GetKeyDown(KeyCode.Space)) { CheckPlayer (); OpenClose(); open = !open; } } void CheckPlayer() { if (Vector3.Dot (door.forward, player.forward) < -0.5f) toPlayer = true; else if (Vector3.Dot (door.forward, player.forward) > 0.5f) { toPlayer = false; } } void OpenClose() { if(open) { if(toPlayer) { door.rotation *= Quaternion.Euler(-doorAngle); } else{ door.rotation *= Quaternion.Euler(doorAngle); } } else { if(toPlayer) { door.rotation *=Quaternion.Euler(doorAngle); } else { door.rotation *= Quaternion.Euler(-doorAngle); } } } } vlt als Anregung
×