- Home /
C# Errors CS1525,CS8025
Unity keeps giving me errors on this script
If any one can help me, please do.
using UnityEngine;
using System.Collections;
public class refuelBox : MonoBehaviour
{
void Start ()
{
GameObject.FindGameObjectWithTag("Ship").GetComponent < shipControls > ().Update();
}
public float reFuelamount()
{
fuelAmount (fuelAmount + 10);
return fuelAmount;
}
void Update()
{
Line 25: float OnTriggerEnter(Collider other)
{
if (other.tag == "Ship")
{
reFuelamount();
}
}
Line 32:}
}
I can not see whats wrong with it.
Error 1: Assets/game/refuelBox.cs(25,30): error CS1525: Unexpected symbol (', expecting
)', ,',
;', [', or
='
and
Error 2: Assets/game/refuelBox.cs(32,5): error CS8025: Parsing error
Answer by syclamoth · Jan 27, 2012 at 01:37 AM
The problem is that you aren't using OnTriggerEnter in the correct way. It should be a seperate function, like Update or Start- and it should return void, not float.
void Update()
{
// It doesn't go in here
}
// it goes out here
void OnTriggerEnter(Collider other)
{
if (other.tag == "Ship")
{
reFuelamount();
}
}
Answer by Eric5h5 · Jan 27, 2012 at 01:42 AM
You can't put a function inside another function, also OnTriggerEnter doesn't return a float.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
How to fix Script? error CS1525: Unexpected symbol `Internal' 3 Answers
Distribute terrain in zones 3 Answers
Unexpected Symbol and Parsing Errors 0 Answers
How to fix Script? error cs1525 Unexpected symbol 'vector3' 0 Answers