Search Results

Search found 4 results on 1 pages for 'ohmrbigshot'.

Page 1/1 | 1 

  • Best algorithm for recursive adjacent tiles?

    - by OhMrBigshot
    In my game I have a set of tiles placed in a 2D array marked by their Xs and Zs ([1,1],[1,2], etc). Now, I want a sort of "Paint Bucket" mechanism: Selecting a tile will destroy all adjacent tiles until a condition stops it, let's say, if it hits an object with hasFlag. Here's what I have so far, I'm sure it's pretty bad, it also freezes everything sometimes: void destroyAdjacentTiles(int x, int z) { int GridSize = Cubes.GetLength(0); int minX = x == 0 ? x : x-1; int maxX = x == GridSize - 1 ? x : x+1; int minZ = z == 0 ? z : z-1; int maxZ = z == GridSize - 1 ? z : z+1; Debug.Log(string.Format("Cube: {0}, {1}; X {2}-{3}; Z {4}-{5}", x, z, minX, maxX, minZ, maxZ)); for (int curX = minX; curX <= maxX; curX++) { for (int curZ = minZ; curZ <= maxZ; curZ++) { if (Cubes[curX, curZ] != Cubes[x, z]) { Debug.Log(string.Format(" Checking: {0}, {1}", curX, curZ)); if (Cubes[curX,curZ] && Cubes[curX,curZ].GetComponent<CubeBehavior>().hasFlag) { Destroy(Cubes[curX,curZ]); destroyAdjacentTiles(curX, curZ); } } } } }

    Read the article

  • Using Lerp to create a hovering effect for a GameObject

    - by OhMrBigshot
    I want to have a GameObject that has a "hovering" effect when the mouse is over it. What I'm having trouble with is actually having a color that gradually goes from one color to the next. I'm assuming Color.Lerp() is the best function for that, but I can't seem to get it working properly. Here's my CubeBehavior.cs's Update() function: private bool ReachedTop = false; private float t = 0f; private float final_t; private bool MouseOver = false; // Update is called once per frame void Update () { if (MouseOver) { t = Time.time % 1f; // using Time.time to get a value between 0 and 1 if (t >= 1f || t <= 0f) // If it reaches either 0 or 1... ReachedTop = ReachedTop ? false : true; if (ReachedTop) final_t = 1f - t; // Make it count backwards else final_t = t; print (final_t); // for debugging purposes renderer.material.color = Color.Lerp(Color.red, Color.green, final_t); } } void OnMouseEnter() { MouseOver = true; } void OnMouseExit() { renderer.material.color = Color.white; MouseOver = false; } Now, I've tried several approaches to making it reach 1 then count backwards till 0 including a multiplier that alternates between 1 and -1, but I just can't seem to get that effect. The value goes to 1 then resets at 0. Any ideas on how to do this?

    Read the article

  • Controlling a GameObject from another GameObject's script component

    - by OhMrBigshot
    I'm creating a game where when starting the game, a Cube is duplicated GridSize * GridSize times when the game starts. Now, after the cubes are duplicated I want to attach a variable to them, say "Flag" which is a bool, from another script component (let's say I have a Prefab that generates the cloned cubes). In short, I have something like this: CreateTiles.cs : Attached to Prefab void Start() { createMyTiles(); // a function that clones the tiles flagRandomTiles(); // a function that (what I'm trying to do) "Flags" 10 random cubes } CubeBehavior.cs : Attached to each Cube public bool hasFlag; // other stuff Now, I want flagRandomTiles() to set a Cube's hasFlag property via code, assuming I have access to them via a GameObject[] array. Here's what I've tried: Cubes[x].hasFlag = true; - No access. Making a function such as Cubes[x].setHasFlag(true) - still no access. Initializing Cubes as a CubeBehavior object array, then doing the above - GameObjects can't be converted to CubeBehaviors - I get this error when I try to assign the Cubes into the array. How do I do this?

    Read the article

  • Use external display from boot on Samsung laptop

    - by OhMrBigshot
    I have a Samsung RV511 laptop, and recently my screen broke. I connected an external screen and it works fine, but only after Windows starts. I want to be able to use the external screen right from boot, in order to set the BIOS to boot from DVD, and to then install a different OS and also format the hard drive. Right now I can only use the screen when Windows loads. What I've tried: I've tried opening up the laptop and disconnecting the display to make it only find the external and use the VGA as default -- didn't work. I've tried using the Fn+key combo in BIOS to connect external display - nothing I've been looking around for ways to change boot sequence without entering BIOS, but it doesn't look like it's possible. Possible solutions? A way to change boot sequence without entering BIOS? Someone with the same brand/similar model to help me blindly keystroke the correct arrows/F5/F6 buttons while in BIOS mode to change boot sequence? A way to force the external display to work from boot, through modifying the internal connections (I have no problem taking the laptop apart if needed, please no soldering though), through BIOS or program? Also, if I change boot sequence without accessing external screen, would the Ubuntu 12.1 installation sequence attempt to use the external screen or would I only be able to use it after Linux is installed and running? I'd really appreciate help, I can't afford to fix the screen for a few months from now, and I'd really like to make my computer come back to decent performance! Thanks in advance!

    Read the article

1