i really dont know why this happens and it happens too much times for me
so here is the part of the script that uses floats but if the whole script is needed im gonna paste it.
i pasted the real one now since you got confused
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class lobbyanddead : MonoBehaviour
{
public GameObject play;
public GameObject scp457;
public GameObject scp008;
public GameObject scp173;
public float blink = 4.0f;
public int health = 100;
public bool infected = false;
void Update()
{
blink -= 1.0f * Time.deltaTime;
if(blink <= 0.9f)
{
blink = 4.0f;
}
if (health <= 1);
{
health = 100;
transform.position = new Vector3(10, 1, -400);
transform.Rotate(0, 0, 0);
}
if(infected == true)
{
health -= 1 * Time.deltaTime;
}
}
void OnCollisionEnter(Collision collision)
{
if (collision.gameObject == play)
{
transform.position = new Vector3(22, 1, -69);
transform.Rotate(0, 0, 0);
}
else if (collision.gameObject == scp457)
{
transform.position = new Vector3(10, 1, -400);
transform.Rotate(0, 0, 0);
}
else if (collision.gameObject == scp008)
{
health -= 10;
infected = true;
transform.Translate(Vector3.forward * Time.deltaTime * 10);
}
else if (collision.gameObject == scp173)
{
if(blink <= 1)
{
transform.position = new Vector3(10, 1, -400);
transform.Rotate(0, 0, 0);
}
}
}
}
}
Paste the, if not the whole script, at least the exact script. Thereâs quite a few things in the code (lowercase âoâ in âcollision.gameObjectâ, = instead of == in the if clause, etc) as written here that would be errors if written in the actual code, which is making it harder to find the actual problem. And always paste the exact error, including the line number, which will point to the actual problem.
When you need help solving syntax problems, every single character is important, so donât try and paraphrase your code, as that will almost always obscure the the real problem.
This statement wonât produce a compile error since it first assign âsomethingâ to âcompare collision.gameobjectâ and then compare the later against null.
But this is probably an undesired behaviour
Youâre currently subtracting Time.deltaTime from health on line 30. Because health is an int, it doesnât have anywhere to store those fractions of numbers, so the data would be lost. The compiler is basically just checking to make sure that that loss is what you intended (and itâs clearly not, in this case).