I dont know if this is th right place for it, but I have problems with this script i wrote for the new boss in my videogame. The boss is supposed to grow bigger when he appears, then show a question if you want to spear him because he is so adorable and if you choose no, the fight starts. The attack is choosen by a random number, if its 1 the following attack is triggered. first the boss is getting smaller until you cant see him anymore then a bool is set to false so it stops getting samller and another is set to true so the teleporting is started, that teleports the boss to a random location. then the bool thing is triggered again and the growing back to its old size is starting. Excuse the german names of the variables and my bad english and if this is in the wrong place. Thank you.
With the help of the comments i figuered out that an if function is working even if its statement is wrong. what is wrong?
here is the script
i dont know why this isnt working
using JetBrains.Annotations;
using System.Collections;
using System.Collections.Generic;
using Unity.Collections;
using UnityEngine;
public class hamstisskripti : MonoBehaviour
{
public Spieler player;
public bool start;
public float displaytime;
public float eins;
public float zwei;
public bool ja;
public Vector3 neu;
public float timer1;
public float weiter1;
public int zufall;
public bool passiert;
public GameObject willstdu;
public bool oins;
public bool zwoi;
public bool droi;
public bool nuul;
public int x;
public int y;
// Start is called before the first frame update
void Start()
{
ja = false;
start = true;
passiert = false;
player = GameObject.FindWithTag("player").GetComponent<Spieler>();
displaytime = 5f;
weiter1 = 10;
oins = false;
zwoi = false;
droi = false;
nuul = false;
}
// Update is called once per frame
void Update()
{
if (player.spielen == true)
{
if (start == true)
{
if (gameObject.transform.localScale.x <= 0.4f)
{
neu = new Vector3(0.0001f, 0.0001f, 0.0001f);
transform.localScale += neu;
}
else
{
start = false;
willstdu.SetActive(true);
}
}
if (start == false)
{
if (ja == true)
{
if (timer1 < weiter1)
{
timer1 = timer1 + Time.deltaTime;
}
else
{
timer1 = 0;
zufall =Random.Range(1, 4);
passiert = false;
}
if (zufall == 1)
{
if (gameObject.transform.localScale.x >= 0f && nuul==true)
{
neu = new Vector3(0.0001f, 0.0001f, 0.0001f);
transform.localScale -= neu;
}
else
{
nuul = false;
oins = true;
}
if (oins == true)
{
oins = false;
Debug.Log("teleportiert");
x = Random.Range(-8, 8);
y = Random.Range(-4, 4);
transform.position = new Vector3(x, y, 0);
oins = false;
zwoi = true;
}
if (zwoi == true)
{
Debug.Log("starte wachstum");
if (gameObject.transform.localScale.x <= 0.4f)
{
Debug.Log("amwachsen");
neu = new Vector3(0.00000001f, 0.00000001f, 0.00000001f);
transform.localScale += neu;
}
else
{
zwoi = false;
}
}
}
}
}
}
}
public void verschonen()
{
player.troll = false;
player.hamsti = true;
willstdu.SetActive(false);
if (gameObject.transform.localScale.x <= 0f)
{
neu = new Vector3(0.0001f, 0.0001f, 0.0001f);
transform.localScale -= neu;
}
this.gameObject.SetActive(false);
}
public void nichtverschonen()
{
ja = true;
willstdu.SetActive(false);
}
public IEnumerator größern()
{
yield return new WaitForSeconds(displaytime);
neu = new Vector3(0.001f, 0.001f, 0.001f);
transform.localScale += neu;
}
}