Please help me out guys!!

Hi there!

I am making a top-down shooter, using the EVAC-CITY tutorial i found at the rebelplanet creations website. I am doing the programming, but whenever i try to run the game, i get the following errors:

Assets/Scripts/AIscript.cs(21,16): error CS0120: UnityEngine.GameObject.tag': An object reference is required for the nonstatic field, method or property** **Assets/Scripts/AIscript.cs(21,16): error CS0120: UnityEngine.GameObject.tag’: An object reference is required for the nonstatic field, method or property
Assets/Scripts/AIscript.cs(50,1): error CS0246: The type or namespace name on' could not be found. Are you missing a using directive or an assembly reference?** **Assets/Scripts/AIscript.cs(61,11): error CS0120: UnityEngine.Rigidbody.AddForce(UnityEngine.Vector3, UnityEngine.ForceMode)': An object reference is required for the nonstatic field, method or property

Assets/Scripts/AIscript.cs(61,11): error CS0120: `UnityEngine.Rigidbody.AddForce(UnityEngine.Vector3)': An object reference is required for the nonstatic field, method or property

I am reasonably new to C# programming, so i do not know what is wrong. Here is the script:

using UnityEngine;
using System.Collections;

public class AIscript : MonoBehaviour {
//game objects (variables which point to game objects)
private GameObject objPlayer;
private GameObject objCamera;
//input variables (variables used to process and handle input)
private Vector3 inputRotation;
private Vector3 inputMovement;
//identity variables (variables specific to the game object)
public float moveSpeed = 100f;
private bool thisIsPlayer;
// calculation variables (variables used for calculation)
private Vector3 tempVector;
private Vector3 tempVector2;
// Use this for initialization
void Start () {
objPlayer = (GameObject) GameObject.FindWithTag ("Player");
objCamera = (GameObject) GameObject.FindWithTag ("MainCamera");
if (GameObject.tag == "Player") { thisIsPlayer = true; }
}
// Update is called once per frame
void Update () {
FindInput();
ProcessMovement();
if (thisIsPlayer == true)
{
HandleCamera();
}
}
void FindInput ()
{
if (thisIsPlayer == true)
{
FindPlayerInput();
} else {
FindAIinput();
}
}
void FindPlayerInput ()
{
// find vector to move
inputMovement = new Vector3( Input.GetAxis("Horizontal"),
0,Input.GetAxis("Vertical") );
// find vector to the mouse
tempVector2 = new Vector3(Screen.width * 0.5f,0,Screen.height *
0.5f); // the position of the middle of the screen
tempVector = Input.mousePosition; // find the position of the moue
on Screen ;
tempVector.z = tempVector.y; // input mouse position gives us 2Dcoordinates, I am moving the Y coordinate to the Z coorindate in temp Vector and setting the Y coordinate to 0, so that the Vector will read the Input along the X (left and right of Screen) and Z (up and down Screen) axis, and not the X and Y (in and out of Screen) axis
tempVector.y = 0;
Debug.Log(tempVector);
inputRotation = tempVector - tempVector2; // the direction we want face/aim/shoot is from the middle of the Screen to where the mouse is pointing
}
void FindAIinput ()
{
}
void ProcessMovement()
{
Rigidbody.AddForce (inputMovement.normalized * moveSpeed * Time.deltaTime);
transform.rotation = Quaternion.LookRotation(inputRotation);
transform.eulerAngles = new Vector3(0,transform.eulerAngles.y + 180,0);
transform.position = new Vector3(transform.position.x,0,transform.position.z);
}
void HandleCamera()
{
objCamera.transform.position = new Vector3(transform.position.x,
15,transform.position.z);
objCamera.transform.eulerAngles = new Vector3(90,0,0);
}
}

Please can you help me, i do not know what to do :frowning:

Thanks in advance,
Michael Brockwell

Please help me guys!!! :!: :!: :!: :!:

The problem you are having with the GameObject and Rigidbody objects is you are trying to call them with the class name. To fix it, you need to use an actual instance of a GameObject and Rigidbody. If you want to use the GameObject and Rigidbody that this script is attached to, you just need to change the following:

if (GameObject.tag == "Player") { thisIsPlayer = true; }
// Changes to
if (gameObject.tag == "Player") { thisIsPlayer = true; }
Rigidbody.AddForce (inputMovement.normalized * moveSpeed * Time.deltaTime);
// Changes to
rigidbody.AddForce (inputMovement.normalized * moveSpeed * Time.deltaTime);

The other error looks like you pressed enter in the middle of the comment and put some stuff that is supposed to be inside a comment on a new line.

tempVector = Input.mousePosition; // find the position of the moue 
on Screen ;
// Changes to
tempVector = Input.mousePosition; // find the position of the mouse on Screen ;

Thank you for helping me out. Now i can finish the project!

thanks again,

Michael Brockwell!