My code is not working and I don't know why please help.

This is my error :Argument 1: cannot convert from ‘int’ to ‘string’ [Assembly-CSharp]

And this is my code :
using UnityEngine;

public class PlayerShoot : MonoBehaviour {
public float fireRate = 0.2f;
public Transform FiringPoint;
public GameObject bulletPrefab;

float timeUntilFire;
PlayerMovement pm;

private void Start() {
pm = gameObject.GetComponent();
}

private void Update() {
if (Input.GetButtonDown(0) && timeUntilFire < Time.time) {
Shoot();
timeUntilFire = Time.time + fireRate;
}
}

void Shoot() {
float angle = pm.isFacingRight ? 0f : 180f;
Instantiate(bulletPrefab, FiringPoint.position, Quaternion.Euler(new Vector3(0f, 0f, angle)));
}
}

you can’t pass a int into the Input.GetButtonDown() use instead GetMouseButtonDown(int button)

1 Like

I feel dumb it told me to do that in the tutorial.

its may happen. Try to check your error message it can give some very good information :slight_smile:

MY issue with this one is that he only shoots to the left instead of where he is facing