hello I am a novice programmer currently I am trying to make an enemy shoot a projectile at the player but I am told that an end of file is expected but I am sure that all the curly braces are there. can someone please help? this is the code
using UnityEngine;
public class Cloud_Bullet : MonoBehaviour { }
public class Nextfire { }
public class FireRate { }
{
[SerializeField]
GameObject FIREBALL_0;
public int FireRate;
public int NextFire;}
// Start is called before the first frame update
void start()
{
{
FireRate = 1f;
Nextfire = Time.time;
}
// Update is called once per frame
void Update()
{
CheckIfTimeToFire();
}
void CheckIfTimeToFire();
Please post your code using Code Tags. Makes it a lot easier for people to help.
Also, it looks like you open and close the class on the Same Line
using UnityEngine;
public class Cloud_Bullet : MonoBehaviour { }
public class Nextfire { }
public class FireRate { }
{
[SerializeField]
GameObject FIREBALL_0;
public int FireRate;
public int NextFire;}
// Start is called before the first frame update
void start()
{
{
FireRate = 1f;
Nextfire = Time.time;
}
// Update is called once per frame
void Update()
{
CheckIfTimeToFire();
}
void CheckIfTimeToFire();
{
if (Time.time > NextFire)
{
Instantiate(Cloud_Bullet, Transform.position, Quaternion.identity);
Nextfire = Time.time + FireRate;
}
}
}
public class Cloud_Bullet : MonoBehaviour { } This line Opens and closes the class.
You also have several other errors;
Declare FireRate as an int, but assigning it a float
Declare NextFire as an int, but trying to use Nextfire (Notice the Capital F in the declaration, but lower case f in the usage) as a Time.time.
pls someone help me heres my script for player movement :
using UnityEngine;
public class PlayerMovement : MonoBehaviour
public CharacterController controller;
public float speed = 12f;
// Update is called once per frame
void Update()
{
float x = Input.GetAxis(“Horizontal”);
float z = Input.GetAxis(“Vertical”);
Vector3 move = transform.right * x + transform.forward * z;
controller.Move(move * speed * Time.deltaTime);
}
}
error : Assets\PlayerMovement.cs(18,1): error CS1022: Type or namespace definition, or end-of-file expected
Probably not a good idea to post your question into some old thread, even if you got the same error.
Usually it is best to start you own thread and use code tags .
But in this case, if you actually had read the posts, you would have found out the reason for your error…
And If you had used code tags and your code was properly indented, it would be obvious you are missing (at least) a “{” in the beginning of your class definition.