- Home /
Other
the problem is part of the code
In general, the problem is on the Android game, part of the code does not work, on the PC it certainly works fine, but for some reason it does not want on the phone. Here is the actual part of the code which should work
public GameObject child
void Update()
{
if (GameObject.FindWithTag("detailWoodL").transform.localEulerAngles.y == 85)
{
conposition = true;
Debug.Log("conected");
}
if (conected == true)
{
if (conposition == true)
{
child.transform.SetParent(parent);
Destroy(child.GetComponent<Rigidbody>());
Debug.Log("TrueandFalse");
}
localEulerAngles.y is a float value and its difficult to make it exactly equal to 85.
Answer by tormentoarmagedoom · Mar 03, 2020 at 07:07 PM
Hello.
First, the title must explain a little whats your problem about. "the problem is part of the code" is giving 0 info.
Second, as @Priyanka-Rajwanshi says, localEulerAngles components are float. You are checking if it is exatcly 85.00000 which is almost impossible to happen. if its 85.0002 it will not become true.
You need to do something like:
if (transform.localEulerAngles.y > 84 && transform.localEulerAngles.y < 86)
thanks, I’ll do it right, but why then on PC it works well
Didnt changed anything on the post.
Post closed.
Follow this Question
Related Questions
Scripting help 1 Answer
how can I disapear a button after push? 1 Answer
Running a script without being attached to an object? 2 Answers
Animation State Machine Script Control Issue 1 Answer
How to minimize an input value? 0 Answers