Jump to content
Search In
  • More options...
Find results that contain...
Find results in...


  • Content Count

  • Joined

  • Last visited


This user doesn't have any awards

About CreepyPL

  • Title

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. CreepyPL

    I need C#/Unity assistance

    I am making a simple mobile game and am decently new to programing, and i try to figure this problem for literally about 2 weeks, and everytime i get back to this problem i face the same thing that i dot understand and doesnt make any sense at all in my opinion. Heres the code: private void OnCollisionEnter2D(Collision2D collision) { if (tag == "Breakable") { NormalBlock(); creepyCoin.AddCCAfterHit(); } else if (tag == "Bomb Block") { BombBlock(); } } private void NormalBlock() { blockHP--; if (blockHP <= 0) { Destroy(gameObject); level.BlockDestroyed(); } blockHPText.text = blockHP.ToString(); } private void BombBlock() { GameObject[] allNormalBlocks = GameObject.FindGameObjectsWithTag("Breakable"); foreach (GameObject obj in allNormalBlocks) { NormalBlock(); } Destroy(gameObject); } } The exact problem i have is that the "NormalBlock" method in the "BombBlock" method doesnt get executed for some reason, it really gives me headache since it makes no sense that it does not work (to me).
  2. CreepyPL

    C#/Unity how to convert TextMeshProUGUI.text to int

    Got it to work, thanks.
  3. The title basically says it. Heres the code: using System.Collections; using System.Collections.Generic; using UnityEngine; using TMPro; using UnityEngine.SceneManagement; public class LevelLoader : MonoBehaviour { [SerializeField] int amountOfScenesBeforeLevels; [SerializeField] TextMeshProUGUI levelNumber; public void LoadNextLevel() { SceneManager.LoadScene(amountOfScenesBeforeLevels + levelNumber.text); Debug.Log(levelNumber.text); Debug.Log(amountOfScenesBeforeLevels); } }
  4. CreepyPL

    I need help with C# and Unity

    omfg! i got it to work, i was thinking about it and this was the first thing i tried "GetComponent<Image>().Color" but "Color" had that red underline, so it wasnt working, now i did the autocomplete of it, and it got a small C, and no red lines!!! and yes indeed that fixed it. Thanks for help
  5. CreepyPL

    I need help with C# and Unity

    I also was thinking of this, but i have never used materials before (other than the physics ones), so i wasnt sure, and probably i could make that happen, i suspect that its not very difficult, but wouldnt it be easier just changing the color. "GetComponent<Image>().material.color" is doing its job, but i got told that this should change the color (it does haha), but not in the right way, i just need to acces the color aspect of the image component.
  6. CreepyPL

    I need help with C# and Unity

    I definetally could use that reference you gave me, and i for sure will, but that wont help me with the code running individually for every component. I temporarly removed the button component to exclude the posibility of that interfering, and you can see from my code that i should acces the right property (and i am, i guess) but it changes that stat globally for some reason, everthing other than that i can handle myself :p, but thx anyways.
  7. CreepyPL

    I need help with C# and Unity

    Sorry, my explaination was pretty crappy (im not very good with english). It was on update (i changed it back to "Start" just after posting) because it was for testing purposes, i rather change a word in the code, than: "click play, wait, see, click play, repeat". I Provided some screenshots, i want to apply this code to the highlited objects, all the buttons are coming from the same prefab, however only one object has the code atached. What i want exactly is that everytime i would load into a scene (currently just the main menu scene), every object would have a random color (red, green, blue, cyan, magenta or yellow). I said that i was not a sprite, i havent even noticed that i said it twice lol, because (i think) that if you would want to change a color of a sprite you dont "GetComponent<Image>" but rather "GetComponent<SpriteRenderer>" i am not sure about that, just guessing (never had to change a sprites color so i am not sure). I hope you can understand it better now, thx for helping me.
  8. CreepyPL

    I need help with C# and Unity

    I need a code that changes the color of all of my game objects (not sprites), but not all to the same color (each object must have a random color). I made a code that asigns the same random color to all of the game objects(not sprites). And i cannot figure this out, i am struggling with this for several hours now, really annoying! Heres the code: using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class RandomizeColors : MonoBehaviour { Vector4[] colors = { new Vector4(1, 0, 0, 1), new Vector4(0, 1, 0, 1), new Vector4(0, 0, 1, 1), new Vector4(0, 1, 1, 1), new Vector4(1, 0, 1, 1), new Vector4(1, 1, 0, 1) }; private Vector4 RandomColor() { Vector4 color = colors[Random.Range(0, colors.Length)]; return color; } private void Update() { GetComponent<Image>().material.color = RandomColor(); } }