- Home /
This question was
closed Jun 23, 2015 at 12:41 PM by
Graham-Dunnett for the following reason:
Duplicate Question
Question by
Amr Mohamed · Jun 23, 2015 at 12:40 PM ·
errorvoidcs1547
Why is the consule contains an error ((51,16): error CS1547: Keyword `void' cannot be used in this context)
using UnityEngine; using System.Collections;
public class PlayerMovement : MonoBehaviour { public GameManager manager;
public float moveSpeed;
public GameObject deathParticles;
private float maxSpeed = 5f;
private Vector3 input;
private Vector3 spawn;
//Use this for inithialization
void Start () {
spawn = transform.position;
}
void FixedUpdate()
{
input = new Vector3 (Input.GetAxisRaw ("Horizontal"), 0, Input.GetAxisRaw ("Vertical"));
if (rigidbody.velocity.magnitude < maxSpeed)
{
rigidbody.AddForce (input * moveSpeed);
}
if (transform.position.y < -1)
{
Die();
}
}
void OnTriggerEnter(Collider other)
{
if (other.transform.tag == "Enemy")
{
Die(); }
if (other.transform.tag == "Goal")
{
manager.CompleteLevel ();
}
}
void OnCollisionEnter (Collision other)
{
if (other.transform.tag == "Enemy")
{
Die();
}
void Die() {
Instantiate(deathParticles, transform.position, Quaternion.Euler(270,0,0));
transform.position= spawn;
}
}
}
Comment
Your error is on line 44 I do believe. (Its often not whats there but whats not there that leads us to a discovery).
I retagged the question for you. If you take the time to follow the link, you'll get an existing question with a perfectly valid answer.