trying to setup a sphere cast to see when a object is in range of my turret
getting
error CS1503: Argument #1' cannot convert
object’ expression to type `UnityEngine.Vector3’
using UnityEngine;
using System.Collections;
public class TurretScript : MonoBehaviour {
public GameObject Target;
public GameObject MachGuns;
public bool AllyTurret;
private bool Aiming;
private bool IsFireing;
private bool AssignTarget;
private float Distance;
public float FireRate = 1f;
public AudioClip Gunz;
public float Ammo = 80;
public float turnspeed = 12;
//--------------------------------------------------------------------
// Update is called once per frame
void Start(){
if (AllyTurret == false) {
Targets = GameObject.FindGameObjectsWithTag ("BlueTeam_Fighter");
index = Random.Range (0, Targets.Length);
Target = Targets [index];
}
}
void Update () {
if (Target != null) {
Aiming = true;
}
if (AssignTarget == true) {
IsFireing = true;
}
if (IsFireing == ture) {
MachGuns.SetActive (true);
} else {
MachGuns.SetActive (false);
}
if (Aiming == true) {
TurretGuns.transform.rotation = Quaternion.Slerp( TurretGuns.transform.rotation, Quaternion.LookRotation(Target.transform.position - transform.position ), Time.deltaTime * turnspeed);
}
//------------------------------------------------------------------------------
RaycastHit hit;
if (AllyTurret == false && Target == null && AssignTarget == false) {
if (Physics.SphereCast (gameobject.transform.position, 1f, gameObject.transform.forward, out hit, 50)) {
if (hit.collider.tag != "Blue_Team_Fighter") {
Target = hit;
AssignTarget = true;
}
}
}
//------------------------------------------------------------------------------
if (AllyTurret == true && Target == null && AssignTarget == false) {
if (Physics.SphereCast (gameobject.transform.position, 1f, gameObject.transform.forward, out hit, 50)) {
if (hit.collider.tag != "Red_Team_Fighter") {
Target = hit;
AssignTarget = true;
}
}
}
//------------------------------------------------------------------------------
// DISANCE:
Distance = Vector3.Distance(Target.position, transform.position);
if (Distance > 50) {
Target = null;
}
}
}