Hey guys ! I’m new and I’m starting to create my own 2D game .
Until now , I’ve a level , plateforms , bonuses and death zones. But when I finished scripting to makes my death zones (trigger collider) , my bonus script doesn’t work anymore and tells me :Unexpected symbol ‘if’ , or Void is not usable in this situation…
Could you help me ? Thank you very much !
Here is my code :
using UnityEngine;
using System.Collections;
public class herosController : MonoBehaviour {
public float maxSpeed = 10.0f;
public Collider2D ground;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
float h = Input.GetAxis (“Horizontal”);
Rigidbody2D rigidbody = GetComponent ();
rigidbody.velocity = new Vector2 (h * maxSpeed, rigidbody.velocity.y);
if (Input.GetButtonDown (“Jump”)) {
rigidbody.velocity = new Vector2 (h * maxSpeed, rigidbody.velocity.y + 7);
}
}
void OnTriggerEnter(Collider2D other)
if(other.gameObject.CompareTag (“Bonus”)) {
other.gameObject.SetActive (false);
}
void OnTriggerEnter2D(Collider2D other) {
if (other.gameObject.CompareTag (“Respawn”)) {
Debug.Log(“Game Over”);
Application.LoadLevel(“Neon dash”);
}
}
}