Cant solve compile errorvplzz help!
0
I have just recently downloaded Unity and using a tutorial on youtube to help me get started. I hav already restarted twice because there were problems with the scripts. So now im almost done but i have two compile errors. Keyword void cannot be used in this context and unexpected symbol. The tutorial required that i add code to an already working script. Just a little bit at the bottom. Here is the entire script. The part that I added starts on line 56. Any help will be greatly appreciated.
using UnityEngine;
using System.Collections;
public class playerscript : MonoBehaviour {
public Vector2 speed = new Vector2(50,50);
void Update() {
float inputX = Input.GetAxis ("Horizontal");
float inputY = Input.GetAxis ("Vertical");
Vector3 movement = new Vector3( speed.x * inputX, speed.y * inputY,0);
movement *= Time.deltaTime;
transform.Translate (movement);
bool shoot = Input.GetButtonDown ("Fire1");
shoot |=Input.GetButtonDown ("Fire2");
if (shoot)
{
WeaponScript weapon = GetComponent<WeaponScript> ();
if (weapon != null)
{
weapon.Attack (false);
SoundEffectsHelper.Instance.MakePlayerShotSound();
}
}
{
var dist = (transform.position - Camera.main.transform.position).z;
var leftBorder = Camera.main.ViewportToWorldPoint(
new Vector3(0, 0, dist)
).x;
var rightBorder = Camera.main.ViewportToWorldPoint(
new Vector3(1, 0, dist)
).x;
var topBorder = Camera.main.ViewportToWorldPoint(
new Vector3(0, 0, dist)
).y;
var bottomBorder = Camera.main.ViewportToWorldPoint(
new Vector3(0, 1, dist)
).y;
transform.position = new Vector3(
Mathf.Clamp(transform.position.x, leftBorder, rightBorder),
Mathf.Clamp(transform.position.y, topBorder, bottomBorder),
transform.position.z
);
// End of the update method
}
void OnDestroy()
{
Transform.parent.gameObject.AddComponentMenu<GameOverScript>();
}
}