- Home /
RAYCAST Forward error CS0131: The left-hand side of an assignment must be a variable, a property or an indexer
hey guys trying to shoot a simple recast to see if their is an enemy target infant of my ship to "Lock Onto"
geting error CS0131: The left-hand side of an assignment must be a variable, a property or an indexer
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class MissileControll : NetworkedMonoBehavior {
RaycastHit hit = new RaycastHit ();
public Missle MissileScript;
public LockedOn LockonGUIScript;
public SpecialGUI Special;
public GameObject Target;
public GameObject GunPoint;
public GameObject AcualMissile;
public GameObject Crosshai1;
public GameObject Crosshai2;
public GameObject MissionControll;
public Vector3 fwd;
public bool IsLockedOnBool;
public bool Activate = false;
public int MissileCount = 5;
public bool FireMissile;
public void Start(){
MissionControll = GameObject.FindGameObjectWithTag ("MissionControll");
Special = MissionControll.GetComponent<SpecialGUI> ();
Special.SpecialNamestring = "Missile".ToString ();
}
public void LateUpdate(){
Special.GUISpecialNumber = MissileCount;
//------------------------------------------------------------------------------------------
if (Target == null) {
Activate = false;
}
//------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------
if (Activate == true) {
RaycastHit hit;
float HitDistance;
fwd = transform.TransformDirection(Vector3.forward) = 10000;
if (Physics.Raycast (transform.position, (fwd), out hit));
Debug.DrawRay(transform.position,fwd,Color.green);
if (hit.collider.gameObject.name == "FighterRed") {
HitDistance = hit.distance;
Target = hit.collider.gameObject;
IsLockedOnBool = true;
LockonGUIScript = Target.GetComponent<LockedOn> ();
LockonGUIScript.IsLockedon = true;
}
if (hit.collider.gameObject.name == "DestroyerRed") {
Target = hit.collider.gameObject;
IsLockedOnBool = true;
LockonGUIScript = Target.GetComponent<LockedOn> ();
LockonGUIScript.IsLockedon = true;
}
}
//------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------
if (Input.GetButtonUp ("LockOn")) {
Crosshai1.SetActive (false);
Crosshai2.SetActive (true);
Activate = true;
}
//------------------------------------------------------------------------------------------
if (Input.GetButtonUp ("LockOf")) {
Crosshai1.SetActive (true);
Crosshai2.SetActive (false);
Activate = false;
LockonGUIScript = Target.GetComponent<LockedOn> ();
LockonGUIScript.IsLockedon = false;
Target = null;
}
if (Input.GetButtonUp ("Shoot2")) {
if (IsLockedOnBool == true) {
FireMissile = true;
}
}
}
public void Update(){
if (FireMissile == true && MissileCount > 0) {
GameObject Clone;
Clone = Instantiate (AcualMissile, GunPoint.transform.position, transform.rotation) as GameObject;
Clone.name = AcualMissile.name;
MissileScript = AcualMissile.GetComponent<Missle> ();
MissileScript.target = Target;
FireMissile = false;
MissileCount -= 1;
}
}
}
Comment
Best Answer
Answer by aditya · Nov 14, 2016 at 09:00 AM
First of all if you are asking about the error occurred then always include the line number and in your case the error is on line number 63
fwd = transform.TransformDirection(Vector3.forward) = 10000;
should be
fwd = transform.TransformDirection(Vector3.forward) * 10000;
above is just an example basically you had to replace your assigning operator with arithmetic operator
Your answer
Follow this Question
Related Questions
Help me in Targeting with Raycast please. 1 Answer
Multiple targeting help 1 Answer
Script to Fire at Objects You Can Hit 4 Answers
drone to target enemies 2 Answers
Problem With Physics.Raycast 1 Answer