Stilllegung des Forums
Das Forum wurde am 05.06.2023 nach über 20 Jahren stillgelegt (weitere Informationen und ein kleiner Rückblick).
Registrierungen, Anmeldungen und Postings sind nicht mehr möglich. Öffentliche Inhalte sind weiterhin zugänglich.
Das Team von spieleprogrammierer.de bedankt sich bei der Community für die vielen schönen Jahre.
Wenn du eine deutschsprachige Spieleentwickler-Community suchst, schau doch mal im Discord und auf ZFX vorbei!
Werbeanzeige
C#-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
void movement() { float rotation = Mathf.CeilToInt (Input.GetAxis ("Mouse X") * Time.deltaTime * RotationsGeschwindigkeit); float elevation = Input.GetAxis ("Mouse Y") * Time.deltaTime * RotationsGeschwindigkeit; float akuteDrehung = (Mathf.FloorToInt (this.transform.localRotation.eulerAngles.y)); float General; if (akuteDrehung >= 360 - Seitenwinkel) { General = akuteDrehung - 360; } else { General = akuteDrehung; } Debug.Log (General); if (General >= (Seitenwinkel * -1) && General <= Seitenwinkel) { this.transform.rotation = Quaternion.AngleAxis (rotation, Vector3.up) * transform.rotation; // Normal (300-360-60) } else { if (akuteDrehung >= Seitenwinkel && rotation < 0 && akuteDrehung < (360 - Seitenwinkel)) { akuteDrehung = Seitenwinkel; this.transform.rotation = Quaternion.AngleAxis (rotation, Vector3.up) * transform.rotation; } this.transform.rotation = transform.rotation * Quaternion.AngleAxis(elevation, Vector3.right); // Rotate around local x axis. } |
C#-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
void movement() { float rotation = Mathf.CeilToInt (Input.GetAxis ("Mouse X") * Time.deltaTime * RotationsGeschwindigkeit); rotation = (roation + 360f) % 360; // Bin mir nicht sicher, ob diese Zeile überhaupt nötig ist float elevation = Input.GetAxis ("Mouse Y") * Time.deltaTime * RotationsGeschwindigkeit; this.transform.rotation = Quaternion.AngleAxis (rotation, Vector3.up) * transform.rotation; // Normal (300-360-60) if(this.transform.eulerAngles.y > Seitenwinkel && this.transform.eulerAngles.y < 360 - Seitenwinkel) { if(this.transform.eulerAngles.y - Seitenwinkel < 360 - Seitenwinkel - this.transform.eulerAngles.y) { this.transform.eulerAngles = new Vector3(this.transform.eulerAngles.x, Seitenwinkel, this.transform.eulerAngles.z); } else { this.transform.eulerAngles = new Vector3(this.transform.eulerAngles.x, 360 - Seitenwinkel, this.transform.eulerAngles.z); } } this.transform.rotation = transform.rotation * Quaternion.AngleAxis(elevation, Vector3.right); // Rotate around local x axis. } |
Werbeanzeige