Question by
PERFKNIGHT · Dec 18, 2015 at 04:57 PM ·
error message
Unknown symbol(s)?
Okay, so I'm making a hovercar game in Unity, and some unknown symbol errors are popping up in the console. I can't seem to find the errors, and I followed a Youtube tutorial to the letter. Help?
using UnityEngine; using System.Collections;
public class PlayerController : MonoBehaviour { public Rigidbody rb; float m_deadzone = 0.1f;
public float forwardAccel = 100.0f;
public float backwardAccel = 25.0f;
float currentThrust = 0.0f;
public float m_turnStrength = 10f;
float m_currTurn = 0.0f;
private float strafe;
private Vector3 strafePos;
private float currentStrafe;
public float strafeRate;
public GameObject shot;
public Transform shotSpawn;
public Transform shotSpawn1;
public float fireRate;
private float nextFire;
private float nextFire1;
int m_layerMask;
public float m_hoverForce = 9.0f;
public float m_hoverHeight = 2.0f;
public GameObject[] m_hoverPoints;
void Start()
{
rb = GetComponent<Rigidbody>();
m_layerMask = 1 << LayerMask.NameToLayer("Player");
m_layerMask = ~m_layerMask;
}
void Update()
{
currentThrust = 0.0f;
float accelAxis = Input.GetAxis("Vertical");
strafe = Input.GetAxis("Horizontal");
m_currTurn = 0.0f;
float turnAxis = Input.GetAxis("RotateHorizontal");
if (Mathf.Abs(turnAxis) > m_deadZone)
{
m_currTurn = turnAxis;
}
if(accelAxis > m_deadzone)
{
currentThrust = accelAxis * forwardAccel;
}
else if(accelAxis < m_deadzone)
{
currentThrust = accelAxis * backwardAccel;
}
if(strafe > m_deadzone)
{
currentStrafe = strafe * strafeRate;
}
else if(strafe < m_deadzone)
{
currentStrafe = strafe * strafeRate;
}
strafePos = Quaternion.Euler(0f, transform.eulerAngles.y,0f) * new Vector3(currentStrafe,0f,0f);
if (Input.GetButton("Shoot") && Time.time > nextFire)
{
nextFire = Time.time + fireRate;
shot.SetActive(true);
Instantiate(shot, shotSpawn.position, shotSpawn.rotation);
}
if (Input.GetButton("Shoot") && Time.time > nextFire1)
{
nextFire1 = Time.time + fireRate;
shot.SetActive(true);
Instantiate(shot, shotSpawn1.position, shotSpawn1.rotation);
}
}
void FixedUpdate()
{
RaycastHit hit;
for(int i = 0; i < m_hoverPoints.Length; i++)
{
var hoverPoint = m_hoverPoints[i];
if(Physics.Raycast(hoverPoint.transform.position,-Vector3.up,out hit,m_hoverHeight,m_layerMask))
{
rb.AddForceAtPosition(Vector3.up * m_hoverForce * (1.0f - (hit.distance / m_hoverHeight)), hoverPoint.transform.position);
}
}
else
{
if(transform.position.y > hoverPoint.transform.position.y)
{
rb.AddForceAtPosition(hoverPoint.transform.up * m_hoverForce, hoverPoint.transform.position);
}
else
{
rb.AddForceAtPosition(hoverPoint.transform.up * -m_hoverForce, hoverPoint.transform.position);
}
}
if(Mathf.Abs(currentThrust) > 0)
{
rb.AddForce(transform.forward * currentThrust);
}
if (m_currTurn > 0)
{
rb.AddRelativeTorque(Vector3.up * m_currTurn * m_turnStrength);
}
else if(m_currTurn < 0)
{
rb.AddRelativeTorque(Vector3.up * m_currTurn * m_turnStrength);
}
if(Mathf.Abs(currentStrafe) > 0)
{
rb.AddForce(strafePos);
}
}
void OnDrawGizmos()
}
Comment
The name 'm_deadZone' does not exist in the current context
'PlayerController.OnDrawGizmos()' must declare a body because it is not marked abstract, extern, or partial
In the fixed update, there is an else without an if before (because of the closing bracket of the for loop)