Quantcast
Channel: Questions in topic: "crash"
Viewing all articles
Browse latest Browse all 2383

Why does while make Unity crash?

$
0
0
Hi there, About a week ago I knew nothing about Unity or even programming in any language so be easy on me..(= I'm playing around with Unity and trying to get a Spine animation to stand idle when no key is pressed and to play a different run animation and move along the x axis when "right" or "left" are pressed. I think I got the moving part right, in this code I tried disabling the idle animation and enabled the run animation whenever I press "right" or "left", for some reason Unity crashes every time I click play. Thanks in advance! `using UnityEngine; using System.Collections; public class movePlayer : MonoBehaviour { public float speed ; private SkeletonAnimation run; private SkeletonComponent idle; void Awake () { run = GetComponent(); idle = GetComponent(); } void Update() { float translation = Input.GetAxis ("Horizontal") * speed; translation *= Time.deltaTime; transform.Translate (translation, 0, 0); bool held = Input.GetButton("Jump"); while(held) { idle.enabled = false; run.enabled = true; } } }`

Viewing all articles
Browse latest Browse all 2383

Trending Articles



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