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

Dialogue related. Can't get this code to work. Any suggestions ?

$
0
0
Hello, I am using the latest version of unity 5 and mine is a 2d game. For the pause dialogue and other dialogues I got everything to work except for one code to fix the problem. And yes I am following a tutorial. Thank you. private bool isGrounded; private float radius = 0.7f; private float force = 325; public Transform coinsParent; public Transform groundPoint; public LayerMask ground; public AudioSource audioSource; public AudioClip Jump; public AudioClip Coin; public AudioClip Win; public Animator animator; public int coins; public Game gameComponent;//Game reference; public TextMesh score; bool shownDialogueType; bool jumped; float jumpTime = 0; float jumpDelay = 0.5f; void Start () { animator = GetComponent (); } // Update is called once per frame void Update() { isGrounded = Physics2D.OverlapCircle(groundPoint.position, radius, ground); if (isGrounded) { if (Input.GetMouseButtonDown(0)) { gameObject.GetComponent().AddForce(Vector2.up * force); audioSource.clip = Jump; audioSource.Play(); jumpTime=jumpDelay; jumped=true; animator.SetTrigger("jumped"); } } jumpTime -= Time.deltaTime; if (jumpTime <=0 && isGrounded && jumped) { animator.SetTrigger("landed"); jumped=false; } } void OnTriggerEnter2D(Collider2D collider2d) { if (collider2d.tag == "Coin") ; { coins++; score.text = coins + ""; Destroy(collider2d.gameObject); audioSource.clip = Coin; audioSource.Play(); } if (collider2d.tag == "DeadZone") { Game.shownDialogueType = Game.DialogType.LOSE; gameComponent.OnGameLose(Game.LoseReason.WRONG_CHOICE); //Application.LoadLevel("level1"); } else if (collider2d.tag == "Finish") { audioSource.clip = Win; audioSource.Play(); }

Viewing all articles
Browse latest Browse all 2891

Trending Articles



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