Quantcast
Channel: Questions in topic: "error"
Viewing all articles
Browse latest Browse all 7934

error CS1612: Cannot modify a value type return value of `UnityEngine.Rigidbody.velocity'.

$
0
0
i need some help modify some c# code ive got everything else down i just need this little part to fix (hopefully) any help? everything ive seen doesnt explain really how to fix the problem. using UnityEngine; using System.Collections; public class Ballcontrol : MonoBehaviour { public int rotationSpeed= 100; public int jumpHeight= 8; private bool playOnce= true; public AudioClip Hit01; public AudioClip Hit02; public AudioClip Hit03; private bool isFalling= false; void Update (){ //Handle ball rotation. float rotation = Input.GetAxis ("Horizontal") * rotationSpeed; rotation *= Time.deltaTime; rigidbody.AddRelativeTorque (Vector3.back * rotation); if (Input.GetKeyDown(KeyCode.W) && isFalling == false) { rigidbody.velocity.y = jumpHeight; playOnceTrue(); } isFalling = true; } void OnCollisionStay (){ if (playOnce == true) { int theHit= Random.Range(0, 4); if (theHit == 0) { audio.clip = Hit01; } else if (theHit == 1) { audio.clip = Hit02; } else { audio.clip = Hit03; } audio.pitch = Random.Range (0.9f,1.1f); audio.Play(); playOnce = false; } isFalling = false; } IEnumerator playOnceTrue (){ yield return new WaitForSeconds (0.2f); playOnce = true; } }

Viewing all articles
Browse latest Browse all 7934

Trending Articles



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