<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://www.uni-weimar.de/kunst-und-gestaltung/wiki/index.php?action=history&amp;feed=atom&amp;title=Unitycode</id>
	<title>Unitycode - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://www.uni-weimar.de/kunst-und-gestaltung/wiki/index.php?action=history&amp;feed=atom&amp;title=Unitycode"/>
	<link rel="alternate" type="text/html" href="https://www.uni-weimar.de/kunst-und-gestaltung/wiki/index.php?title=Unitycode&amp;action=history"/>
	<updated>2026-06-10T10:34:15Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.39.6</generator>
	<entry>
		<id>https://www.uni-weimar.de/kunst-und-gestaltung/wiki/index.php?title=Unitycode&amp;diff=83091&amp;oldid=prev</id>
		<title>TVischer: Created page with &quot;==Jump Script listening to Osc commands==  using UnityEngine; using System.Collections;  public class jump : MonoBehaviour {  	public float jumpForce; 	public AudioClip[] audioCl...&quot;</title>
		<link rel="alternate" type="text/html" href="https://www.uni-weimar.de/kunst-und-gestaltung/wiki/index.php?title=Unitycode&amp;diff=83091&amp;oldid=prev"/>
		<updated>2016-05-31T14:33:07Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;==Jump Script listening to Osc commands==  using UnityEngine; using System.Collections;  public class jump : MonoBehaviour {  	public float jumpForce; 	public AudioClip[] audioCl...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Jump Script listening to Osc commands==&lt;br /&gt;
&lt;br /&gt;
using UnityEngine;&lt;br /&gt;
using System.Collections;&lt;br /&gt;
&lt;br /&gt;
public class jump : MonoBehaviour {&lt;br /&gt;
&lt;br /&gt;
	public float jumpForce;&lt;br /&gt;
	public AudioClip[] audioClip;&lt;br /&gt;
&lt;br /&gt;
	public float moveForward;&lt;br /&gt;
&lt;br /&gt;
	private Rigidbody myRigidbody;&lt;br /&gt;
&lt;br /&gt;
	public static bool canJump = false;&lt;br /&gt;
&lt;br /&gt;
	public string RemoteIP = &amp;quot;127.0.0.1&amp;quot;; &lt;br /&gt;
&lt;br /&gt;
	// the port IanniX is listening on (we send messages to)&lt;br /&gt;
	public int RemotePort = 1234; &lt;br /&gt;
&lt;br /&gt;
	// the port that Unity is listening only listening port matters for receiving&lt;br /&gt;
	public int LocalPort = 12001; &lt;br /&gt;
&lt;br /&gt;
	private Osc osc;&lt;br /&gt;
	private Udp udp;&lt;br /&gt;
	//-&amp;gt;might use these instead!&lt;br /&gt;
	Animator myAnimator;&lt;br /&gt;
	OscMessageHandler AllMessageHandler;&lt;br /&gt;
&lt;br /&gt;
	// define the audio clips&lt;br /&gt;
	public AudioClip clipGround;&lt;br /&gt;
	public AudioClip clipHandschuh;&lt;br /&gt;
	public AudioClip clipSuccess; &lt;br /&gt;
	public AudioClip clipFailure;&lt;br /&gt;
&lt;br /&gt;
	private AudioSource audioGround;&lt;br /&gt;
	private AudioSource audioHandschuh;&lt;br /&gt;
	private AudioSource audioSuccess;&lt;br /&gt;
	private AudioSource audioFailure;&lt;br /&gt;
&lt;br /&gt;
	GameObject handschuh;&lt;br /&gt;
&lt;br /&gt;
	private bool succeeded;&lt;br /&gt;
&lt;br /&gt;
	void OnCollisionEnter (Collision other){&lt;br /&gt;
		if (other.gameObject.tag == &amp;quot;ground&amp;quot;) {&lt;br /&gt;
			canJump = true;&lt;br /&gt;
			Debug.Log (&amp;quot;collision with ground&amp;quot;);&lt;br /&gt;
			audioGround.Play();&lt;br /&gt;
&lt;br /&gt;
			if (handschuh.transform.position.x &amp;lt; transform.position.x) {&lt;br /&gt;
				if (!succeeded) {&lt;br /&gt;
					audioSuccess.Play ();&lt;br /&gt;
					succeeded = true;&lt;br /&gt;
				}&lt;br /&gt;
				if (handschuh.transform.position.x + 4 &amp;lt; transform.position.x) {&lt;br /&gt;
					Application.LoadLevel (0);&lt;br /&gt;
				}&lt;br /&gt;
			}&lt;br /&gt;
&lt;br /&gt;
			}&lt;br /&gt;
		else if (other.gameObject.tag == &amp;quot;boxhandschuh&amp;quot;) {&lt;br /&gt;
			audioHandschuh.Play ();&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	// Use this for initialization&lt;br /&gt;
	void Start () {&lt;br /&gt;
&lt;br /&gt;
		myRigidbody = GetComponent&amp;lt;Rigidbody&amp;gt; ();&lt;br /&gt;
		myAnimator = GetComponent&amp;lt;Animator&amp;gt; ();&lt;br /&gt;
&lt;br /&gt;
		// Verbindungen über Udp und Osc laden&lt;br /&gt;
		udp = (Udp) GetComponent(&amp;quot;Udp&amp;quot;);&lt;br /&gt;
		osc = (Osc) GetComponent(&amp;quot;Osc&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
		udp.init(RemoteIP, RemotePort, LocalPort);&lt;br /&gt;
		osc.init(udp);&lt;br /&gt;
&lt;br /&gt;
		osc.SetAllMessageHandler(AllMessageHandler);&lt;br /&gt;
&lt;br /&gt;
		handschuh = GameObject.FindGameObjectWithTag(&amp;quot;boxhandschuh&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	void Awake(){&lt;br /&gt;
		//from http://answers.unity3d.com/questions/240468/how-to-play-multiple-audioclips-from-the-same-obje.html&lt;br /&gt;
		audioGround = AddAudio(clipGround, false, false, 0.2f);&lt;br /&gt;
		audioHandschuh = AddAudio(clipHandschuh, false, false, 0.4f);&lt;br /&gt;
		audioSuccess = AddAudio(clipSuccess, false, false, 0.8f);&lt;br /&gt;
		audioFailure = AddAudio(clipFailure, false, false, 0.8f); &lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
	// Update is called once per frame&lt;br /&gt;
	void Update () {&lt;br /&gt;
		&lt;br /&gt;
		if (Input.GetKeyDown (KeyCode.Space) || Osc.MessageWas) {&lt;br /&gt;
				&lt;br /&gt;
			Osc.MessageWas = false;&lt;br /&gt;
&lt;br /&gt;
			if (canJump == true) {&lt;br /&gt;
				myRigidbody.velocity = new Vector3 (0, jumpForce, 0);&lt;br /&gt;
				canJump = false;&lt;br /&gt;
&lt;br /&gt;
			}&lt;br /&gt;
		}&lt;br /&gt;
	&lt;br /&gt;
		if (transform.position.y &amp;lt; -3) {&lt;br /&gt;
			audioFailure.Play ();&lt;br /&gt;
		}&lt;br /&gt;
		if (transform.position.y &amp;lt; -7) {&lt;br /&gt;
			//SceneManager.LoadScene (0);&lt;br /&gt;
			Application.LoadLevel (0);&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
	void OnDisable()&lt;br /&gt;
	{&lt;br /&gt;
		Debug.Log(&amp;quot;Closing UDP socket&amp;quot;);&lt;br /&gt;
		osc.Cancel();&lt;br /&gt;
		osc = null;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	public AudioSource AddAudio (AudioClip clip, bool loop, bool playAwake, float vol) {&lt;br /&gt;
&lt;br /&gt;
		AudioSource newAudio = gameObject.AddComponent&amp;lt;AudioSource&amp;gt;();&lt;br /&gt;
&lt;br /&gt;
		newAudio.clip = clip;&lt;br /&gt;
		newAudio.loop = loop;&lt;br /&gt;
		newAudio.playOnAwake = playAwake;&lt;br /&gt;
		newAudio.volume = vol;&lt;br /&gt;
&lt;br /&gt;
		return newAudio;&lt;br /&gt;
&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
}&lt;/div&gt;</summary>
		<author><name>TVischer</name></author>
	</entry>
</feed>