Hi, I’m very new to Unity, and I’m following tutorials my professor has been giving to my class, but I keep getting this error: “Assets\Scripts\EnemyProjectile.cs(19,12): error CS0029: Cannot implicitly convert type ‘float’ to ‘bool’” I’m trying to implement projectiles at the moment, but I cannot wrap my head around how to fix this error. The script is relatively short, and there are other scripts in my project too, but I doubt that they’re interfering with this one.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EnemyProjectile : MonoBehaviour
{
public int damageAmount;
public float speed;
public float ifMoves;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
if (ifMoves)
{
transform.Translate(Vector2.down * speed * Time.deltaTime);
}
}
private void OnTriggerEnter2D(Collider2D collision)
{
if(collision.tag == "Player")
{
collision.GetComponent<SpaceshipControls>().TakeDamage(damageAmount);
Destroy(gameObject);
}
}
}