Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Zaphod42
Sep 13, 2012

If there's anything more important than my ego around, I want it caught and shot now.
Every time I try to write an algorithm to gently sweep over a range of colors I always find it way more of a pain than I anticipate lol

Raenir Salazar posted:

Initial results from just playing with hue:



Hey that looks pretty dang good man

Adbot
ADBOT LOVES YOU

Raenir Salazar
Nov 5, 2010

College Slice

Zaphod42 posted:

Every time I try to write an algorithm to gently sweep over a range of colors I always find it way more of a pain than I anticipate lol


Hey that looks pretty dang good man

Yup, right now I'm playing with how to vary it up more playing with Saturation and brightness since many of those hues are hard to distinguish from each other, so varying by saturation and brightness should help break it up and from there I'll be intending to shuffle then.

It won't gaurantee no two similar colours are next to each other but it'll be good enough.

Impotence
Nov 8, 2010
Lipstick Apathy
Is there some kind of library for doing extremely simple rendering of isometric tiles in-browser? Ideally something where I can effectively pass in a JSON file and attach some click handlers? No tilemaps/Tiled format.

The only thing I really care about is being able to handle hover/touch/click events and get the x,y of the square. I'm not sure if I want a full game engine; most of the interaction will be JS-native modals/popups, not everything rendering within a canvas.

CH Science
Sep 11, 2019

Biowarfare posted:

Is there some kind of library for doing extremely simple rendering of isometric tiles in-browser?

http://www.travisojs.com/blog/tutorial/2015/03/15/basic-isometric-world.html might be worth a look

Impotence
Nov 8, 2010
Lipstick Apathy

Thanks!

This was part of the problem when I was spending several hours looking for what's available, many of them look nice but are some odd non-module proof of concept, blog example, or otherwise; this one seems like it hasn't been updated in years and is pulling in a significantly older major-version of pixi.

I also found Isomer (no images, only shapes?), and JSIso (jquery, xml, inability to use any bundling or optimisation tools like rollup or webpack, ...).

Impotence fucked around with this message at 20:18 on Oct 12, 2020

Raenir Salazar
Nov 5, 2010

College Slice
Red Blob Games also has good information about that sort of stuff too I think.

TIP
Mar 21, 2006

Your move, creep.



Rhyme Storm is now available for purchase!

https://store.steampowered.com/app/1250350/Rhyme_Storm/

After 2.5 years it feels good!

It's been crazy watching all the streams, also, incredibly nerve wracking. Just sitting there, fists clenched, wanting them to do well and hoping the game works correctly. :suspense:

TooMuchAbstraction
Oct 14, 2012

I spent four years making
Waves of Steel
Hell yes I'm going to turn my avatar into an ad for it.
Fun Shoe
Congrats on the launch!

TheLastManStanding
Jan 14, 2008
Mash Buttons!

Raenir Salazar posted:

It won't gaurantee no two similar colours are next to each other but it'll be good enough.

It only takes 4 colors to color a map. If you're using significantly more colors then it should be quick and easy enough to check each edge of your triangulation to see if any neighboring vertexes are using the same colors.

KillHour
Oct 28, 2007


TheLastManStanding posted:

It only takes 4 colors to color a map. If you're using significantly more colors then it should be quick and easy enough to check each edge of your triangulation to see if any neighboring vertexes are using the same colors.

4 is proven possible, but not trivial in all cases. 5 is easier to implement, and much faster (linear time) to compute. https://en.wikipedia.org/wiki/Five_color_theorem

Raenir Salazar
Nov 5, 2010

College Slice

TheLastManStanding posted:

It only takes 4 colors to color a map. If you're using significantly more colors then it should be quick and easy enough to check each edge of your triangulation to see if any neighboring vertexes are using the same colors.

Well to be fair just by how I generate them no two should be the same regardless as every colour is unique. I'd aesthetically prefer that no two similar colours are adjacent just for spot checking purposes but it has no effect otherwise and it's not a hard requirement.

Jabor
Jul 16, 2010

#1 Loser at SpaceChem
Instead of generating colours from the entire spectrum, you could partition the range of hues into five different buckets, with gaps in between them. Assign each region to a bucket so that no two adjacent regions are in the same bucket, give each region a colour from its bucket, and now you've guaranteed that adjacent regions are sufficiently far apart hue-wise.

awesomeolion
Nov 5, 2007

"Hi, I'm awesomeolion."

I was spitballing starting an open source unity project and SupSuper mentioned there was some interest in making a Wario Ware clone. So I started a project called openware! To be clear, I've done very little. I'm under no illusion that what I've made so far is good, but I think it's enough of a skeleton that people can jump in and add new mini games if they feel like it. Also it would be cool to add those Wario Ware style time attack modes and such.



https://github.com/aidan-waite/openware

awesomeolion fucked around with this message at 13:06 on Oct 13, 2020

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!
I'm trying to poke NoesisGUI/Unity with a stick and I'm kind of stuck right at the front door. I am not intimidated by XAML but rather installation and workflow. I just got a little overwhelmed with the setup last night. It sounds like I should:

1. Create a separate project in Microsoft Blend
2. Create my (empty) XAML files in Unity, or at least in my Unity project
3. Link those XAML files into my Blend project as existing items
4. Edit away in Blend

Is this the right idea? How does messing around in Blend correlate to what I get in Unity?

Second, I see that NoesisGUI in Unity's own store is still at version 2, but offline line it's version 3. Is there any particular reason I might want to stick with 2? I'm wondering if licensing changed or something. My first impressions is that they're very similar but 3 can work with consoles and also takes care of an interference with ProGrids that I had with 2.

Side rant: I decided to take the plunge after working on that horizontal alignment hierarchy thing I previously posted. I think I got it right but I was just poking various parameters until it appeared to work. Afterwards, I decided I needed to add a third entry for it. I copy-pasted the other canvas I was using already and just attached different logic for what it should show. It ended up showing nothing. After a lot of just clicking back-and-forth and seeing the settings, I determined the copied one had its scaling set to 0 somehow. Stuff like that is driving me crazy.

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!

awesomeolion posted:

Tap SPACEBAR to graduate
lol this looks like an in-page ad for a for-profit university. I was kind of taken aback for a second.

Raenir Salazar
Nov 5, 2010

College Slice


I think I got an acceptable amount of discrete variation between tiles now prior to shuffling.

code:
    private Color[] GetUniqueColours(int totalPoints)
    {

        Color[] colors = new Color[totalPoints];

        UnityEngine.Debug.Log("total sites: " + totalPoints);
        int totalHues = totalPoints;
        float hueIncrement = (float)maxHue / totalHues;
        int maxSVRange = 10;

        for (int i = 0; i < totalHues; i++)
        {
            float h = (i * hueIncrement) / 360;
            float s = Utils.Remap((i) % maxSVRange, 0, maxSVRange, 0.5f, 1);
            float v = Utils.Remap((i) % maxSVRange, 0, maxSVRange, 0.5f, 1);
            colors[i] = Color.HSVToRGB(h, s, v);
        }

        return colors;
    }
I'm pretty happy with this, now I just need to be able to have it be able to exclude colour ranges.

KillHour
Oct 28, 2007


Isn't that always going to give you identical saturation and value results? I.e.: darker colors will always be less saturated than lighter colors.

Raenir Salazar
Nov 5, 2010

College Slice

KillHour posted:

Isn't that always going to give you identical saturation and value results? I.e.: darker colors will always be less saturated than lighter colors.

Perhaps, I'm still playing with it a little.

e: How's this:



code:
    private Color[] GetUniqueColours(int totalPoints)
    {

        Color[] colors = new Color[totalPoints];

        UnityEngine.Debug.Log("total sites: " + totalPoints);
        int totalHues = totalPoints;
        float hueIncrement = (float)maxHue / totalHues;
        int maxSVRange = 10;

        for (int i = 0; i < totalHues; i++)
        {
            float h = (i * hueIncrement) / 360;
            float s = 1;
            float v = 1;

            if (i % 2 == 0)
            {
                s = Utils.Remap((i) % maxSVRange, 0, maxSVRange, 0.5f, 1);
            }
            else
            {
                v = Utils.Remap((i) % maxSVRange, 0, maxSVRange, 0.5f, 1);
            }

            colors[i] = Color.HSVToRGB(h, s, v);
        }

        return colors;
    }
Saturation now only varies when i is even; otherwise Brightness adjusts instead.

Hrm, I kind of liked the earlier gradient more.

e2: I think doing it like this also skips over some values of i, which might explain why it isn't as nice of a gradient. I could probably double MaxSVRange to try to get back the past effect.



Which seems to be a little different, so I need to work it a little better.

Raenir Salazar fucked around with this message at 00:31 on Oct 14, 2020

KillHour
Oct 28, 2007


Why don't you nest multiple loops so you increment only one property at a time? That should give you a good mix of all ranges and allow you to use modulus logic to select colors that are similar or different in specific ways (if your loop has 4 brightnesses and 4 saturations, specific hues will always be in 16 block chunks, specific brightnesses will be one every 4 colors and specific saturations will be 4 in a row with 12 in between. Therefore, making sure no two adjacent colors are less than 16 apart or have a difference divisible by 4 will guarantee a difference in all 3 values from their neighbor).

Raenir Salazar
Nov 5, 2010

College Slice

KillHour posted:

Why don't you nest multiple loops so you increment only one property at a time? That should give you a good mix of all ranges and allow you to use modulus logic to select colors that are similar or different in specific ways (if your loop has 4 brightnesses and 4 saturations, specific hues will always be in 16 block chunks, specific brightnesses will be one every 4 colors and specific saturations will be 4 in a row with 12 in between. Therefore, making sure no two adjacent colors are less than 16 apart or have a difference divisible by 4 will guarantee a difference in all 3 values from their neighbor).

This is a good idea and I was trying it but I got a little stuck on how best to setup the loops to work for any arbitrary n.

KillHour
Oct 28, 2007


Raenir Salazar posted:

This is a good idea and I was trying it but I got a little stuck on how best to setup the loops to work for any arbitrary n.

Don't. Just overshoot and subsample. I posted some code earlier in the page that I think might work well for what you're looking to do.


In other, semi related news, I've been following the development videos for Sapiens for a while now, but I wanted to post this one because Dave's solution for mapping textures to a procedural world is absolutely brilliant.

https://www.youtube.com/watch?v=9BPsEH-0M3s

Edit: If you REALLY don't want to generate extras, you could always do something like this:

code:
var i = 0;
var maxColors = 123;
var valueBands = 4; //This could be derived from some function on maxColors
var saturationBands = 4; //This could be derived from some function on maxColors

while(true) {
  for(var j = 0; j < valueBands; j++) {
    for(var k = 0; k < saturationBands; k++) {
      //Some code to generate colors
      i++;
      if (i == maxColors) {
        goto ExitColorLoop
      }
    }
  }
}
ExitColorLoop:
//More code

KillHour fucked around with this message at 04:37 on Oct 15, 2020

LordSaturn
Aug 12, 2007

sadly unfunny

for my money, any value that needs to vary in visually pleasing ways over a 2d or 3d space? that's a problem for my man Perlin

I had a lot of fun doing "warped" vector graphics by having each vertex sample a set of perlin maps to determine how far to be off in X and Y (and maybe hue, it's been a bit). can also do a 3d perlin over a 2d space to get smooth animated rippling

KillHour
Oct 28, 2007


LordSaturn posted:

for my money, any value that needs to vary in visually pleasing ways over a 2d or 3d space? that's a problem for my man Perlin

I had a lot of fun doing "warped" vector graphics by having each vertex sample a set of perlin maps to determine how far to be off in X and Y (and maybe hue, it's been a bit). can also do a 3d perlin over a 2d space to get smooth animated rippling

They want to guarantee a minimum amount of contrast, which perlin would be bad at.

Raenir Salazar
Nov 5, 2010

College Slice

KillHour posted:

Don't. Just overshoot and subsample. I posted some code earlier in the page that I think might work well for what you're looking to do.


In other, semi related news, I've been following the development videos for Sapiens for a while now, but I wanted to post this one because Dave's solution for mapping textures to a procedural world is absolutely brilliant.

https://www.youtube.com/watch?v=9BPsEH-0M3s

Edit: If you REALLY don't want to generate extras, you could always do something like this:

code:
var i = 0;
var maxColors = 123;
var valueBands = 4; //This could be derived from some function on maxColors
var saturationBands = 4; //This could be derived from some function on maxColors

while(true) {
  for(var j = 0; j < valueBands; j++) {
    for(var k = 0; k < saturationBands; k++) {
      //Some code to generate colors
      i++;
      if (i == maxColors) {
        goto ExitColorLoop
      }
    }
  }
}
ExitColorLoop:
//More code

Would you be suggesting I do ideally is generate like 6,000 colours and then pick some subset from there? My main concern was handling some unspecified remainder if it didn't fit neatly in the loop but I probably don't need to worry about that if I just generate a fixed amount given an n. Like 1,000 if n is like 513 and 2,000 if n is like 1215, etc? I'll give it a shot!

Currently I'm fiddling with offset; I first got offset working but then had the idea that maybe it would be easier/clearer to let minimum hue go negative and wrap around but that's not working so back to using offset instead.


KillHour posted:

They want to guarantee a minimum amount of contrast, which perlin would be bad at.

Specifically I said this was a nice to have for two tiles to have minimum contrast so I can glance and make sure everything seems right; but they do all have to be unique for Picking purposes.

Raenir Salazar
Nov 5, 2010

College Slice
Updates.

I went and tried the code suggested before, after some minor modifications I'm quite happy with the results:





1144 vs 103 tiles.

I like how in my folder the colours blend together to form something that resembles a cross-eye puzzle:



code:
    private Color[] GetUniqueColours2(int totalPoints)
    {
        List<Color> colors = new List<Color>();

        UnityEngine.Debug.Log("total sites: " + totalPoints);
        int maxHues = totalPoints;

        (int, int) hueRange = (0, 360);
        (int, int) satRange = (50, 100);
        (int, int) valRange = (50, 100);

        // I recommend introducing some randomness in the generation so you don't end up with a TOO obviously generated result
        float hueJitter = 0.05f;
        float satJitter = 0.05f;
        float valJitter = 0.05f;

        int satCount = 10; // Number of saturation bands to generate.  Must be greater than 1 to avoid a div/0 error.
        int valCount = 10; // Number of value bands to generate.  Must be greater than 1 to avoid a div/0 error.

        // This will generate 1000 colors (10*10*10).  To set (approximate) number of colors directly, use cubic root of n for each.
        int hueCount = 10; // Number of hues to generate. Must be greater than 1 to avoid a div/0 error.

        // making hueCount closer to the number of sites
        // will be slightly more if there is a remainder.
        hueCount = Mathf.CeilToInt((float)totalPoints / (valCount * satCount));

        if (hueCount < 10) hueCount = 10;


        for (int i = 0; i < hueCount; i++)
        {
            for (int j = 0; j < satCount; j++)
            {
                for (int k = 0; k < valCount; k++)
                {
                    var hue = Mathf.Lerp(hueRange.Item1, hueRange.Item2, ((float)i / (hueCount - 1)) + Random.Range(-hueJitter, hueJitter));
                    var sat = Mathf.Lerp(satRange.Item1, satRange.Item2, ((float)j / (satCount - 1)) + Random.Range(-satJitter, satJitter));
                    // This gives a fully linear distribution, however people don't see brightness linearly.  
                    // Recommend using gamma scaling instead.  This is left as an exercise to the reader :)
                    var val = 
                        Mathf.Lerp(valRange.Item1, 
                                   valRange.Item2, 
                                   ((float)k / (valCount - 1)) + Random.Range(-valJitter, valJitter));       
                    // Unity'd HSVToRGB function wants it in 0...1 ranges              
                    colors.Add(Color.HSVToRGB(hue / 360, sat / 100, val / 100));

                }
            }
        }

        // normalize the produced colours to the number we want
        List<Color> temp = new List<Color>();
        float amt = (float)colors.Count / totalPoints;
        for (int i = 0; i < totalPoints; i++)
        {
            int index = Mathf.RoundToInt(i * amt);
            temp.Add(colors[index]);
        }

        return temp.Take(totalPoints).ToArray();
    }
The hueCount = 10 then I changed my mind, oops, make it 10 again part I can probably simplify but is largely a result of being clever biting my in the face.

Main issue is if I produce 1,000 colours I want basically a normalized "spread" of sorts but I managed a solution.

Results are pretty good. I'll still need to shuffle them but it's pretty good.

e: Shuffled.

Raenir Salazar fucked around with this message at 01:07 on Oct 18, 2020

Sex Tragedy
Jan 28, 2007

father of three with an extra large butt
How bad is it really to have way too many materials being rendered in Unity? From what I'm reading the state of our project is a great way to pin the cpu.

It goes on like this for a huge rear end folder.

We've been using the google poly api, loading up our set with assets from their library. It seems that google creates a different material for every hue, instead of using vertex color data. I believe it wouldn't be that hard to write something to find every prefab doing this and just load up the vertices with the color value from what they call the base color factor, but I want to know if this will really help my performance. I'm on a deadline and want to know if its worth my time. I've been anxious to show this project off on the forums but want it to be at a certain level of quality. Please provide any knowledge you have. I'd really appreciate someone just telling me "of course you can't have dozens and dozens of materials noob" or "they fixed it must be something else."Thank you very much goons.

TooMuchAbstraction
Oct 14, 2012

I spent four years making
Waves of Steel
Hell yes I'm going to turn my avatar into an ad for it.
Fun Shoe
Are you actually experiencing performance issues, or just worried that you might be?

I mean, I have no clue re: materials, but the rule of thumb for performance is "don't bother until it becomes a problem". So wait for someone to say "hey I really want to play your game but my computer is an abacus and I'm getting only 15 FPS" and then maybe worry about it.

Sex Tragedy
Jan 28, 2007

father of three with an extra large butt
The game is only run on one pc, then streamed out to twitch so people can interact that way. The guy running it was having crazy performance issues, but it turns out it had something to do with a hosed up overclock.

Koramei
Nov 11, 2011

I have three regrets
The first is to be born in Joseon.

Oh dang, I've seen your posts in the Paradox threads for ages but I had no idea you were working on this kind of thing. That's super cool.


Anyway hey thread, I've been learning Unity for the past year or so and I'm kicking myself for not having looked for this kinda thread sooner. Pretty interesting to see peoples' projects!

Raenir Salazar
Nov 5, 2010

College Slice

Koramei posted:

Oh dang, I've seen your posts in the Paradox threads for ages but I had no idea you were working on this kind of thing. That's super cool.


Anyway hey thread, I've been learning Unity for the past year or so and I'm kicking myself for not having looked for this kinda thread sooner. Pretty interesting to see peoples' projects!

I've been trying to recruit people into my sunday game for ages too :D (We're converting to Victoria II next week)

Basically the idea motivating this project is that I feel like we have a LOT of problems where if you have the same group of players over enough years of these games the national strategies and positions of certain "nation-slots" becomes basically a nigh on solved problem; which results in big problems, like if a weaker player is playing a more essential slot like Great Britain or France, and the best players just run away with the game as "Russia"/"Turkey"/Japan/"Germany"; hopefully my theory is by more genuinely randomizing the game's geography we can have some more meaningfully different game experiences even with the same group of people. You're long term strategy now you have to assess essentially on the fly.

Conventional wisdom like, "Russia that's left alone to expand east ruins the game" becomes impossible when the game is essentially random in the geography and the resulting distribution and allotment of player slots.

I've currently come up with a new strategy based on someone's suggestion in my game (who is working on their own separate procedural generation project but for symmetrical "settler's of catan" style maps and written in python so our projects are incompatible on multiple levels!) where I generate my base layer of small voronoi cells and then a separate map of larger cells (as before) but instead of colouring them separately and overlaying them by colouring a land layer cell white; I instead sample the closest cell site on the corresponding terrain layer and colour it according to that cell colour.

This should eliminate slivers and probably be faster than using some sort of flood fill brute force solution; it costs me having Paradox style shaped (polygonal) sea zones and instead makes them more blobby but honestly this solution is probably best and lets me solve the sea zone to ocean zone problem as well.

TheHoosier
Dec 30, 2004

The fuck, Graham?!

Incredibly stupid Unity3d newbie question incoming. Sorry if this is the wrong thread for it:

Why don't my buttons work?! I did babby's first Flappy Bird clone to get my feet wet, and everything seems to be going really well. I decided to get cute and add some buttons to the screen because I want my son to have an easier time playing it, and the drat things don't work: Here's the Canvas settings, and the settings for the Pause button (there's also a Play and Quit button with similar settings):



And here's the UI code:

quote:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
using UnityEngine.UIElements;

public class Pause : MonoBehaviour
{
private GameObject[] pauseObjects;
private GameObject pauseButton;

// Set before initialization
void Start()
{
Time.timeScale = 1;
pauseObjects = GameObject.FindGameObjectsWithTag("ShowOnPause");
pauseButton = GameObject.FindGameObjectWithTag("PauseButton");

hidePaused();

}

// Update is called once per frame
void Update()
{
}
public void OnTouch()
{
if(Time.timeScale == 1)
{
Time.timeScale = 0;
showPaused();
Debug.Log("hi");
}
else if(Time.timeScale == 0)
{
Time.timeScale = 1;
hidePaused();
}
}
public void Reload()
{
SceneManager.LoadScene(0);
}
public void pauseControl()
{
if(Time.timeScale == 1)
{
Time.timeScale = 0;
showPaused();
}
else if(Time.timeScale == 0)
{
Time.timeScale = 1;
hidePaused();
}
}
public void showPaused()
{
foreach(GameObject g in pauseObjects)
{
g.SetActive(true);
}
}
public void hidePaused()
{
foreach(GameObject g in pauseObjects)
{
g.SetActive(false);
}
}
}

I've tried looking up various button fixes and nothing seems to work. They don't animate or trigger when I test it on my phone, nor in the Game window of the Unity3D program. I've tweaked the Z position, raycast checkboxes, input settings, etc. I'm sure it's something simple but I can't figure it out.

dreamless
Dec 18, 2013



Nothing there looks obviously wrong? What it usually is in my projects is there's some other UI object that's blocking it; there's a function I don't remember offhand that tells you what the mouse pointer is over, and debug printing that in an Update() is the simplest way to find out.

chglcu
May 17, 2007

I'm so bored with the USA.
Is OnTouch actually being called? If not, I would guess you may have the wrong object specified in your OnClick handler in the UI. Looks like it's currently set to something called UiManager, which may not be the thing that has your Pause component attached.

Metos
Nov 25, 2005

Sup Ladies
Yeah first step I'd do would be to move the debug.log inside OnTouch to above the if statements.

Could also be floating point accuracy loss, where because Time.timeScale is a float its actual value might be at ~.99995 instead of 1 and so is not equal to 1 when you check. The easy version is to check if its >.9 or <.1 instead of == 1 and == 0.

chglcu
May 17, 2007

I'm so bored with the USA.
Unity also has Mathf.Approximately() to handle floating point inaccuracy. I wouldn't expect that to be the problem here, since 1.0 is expressible exactly in a float and I'd assume it was initialized to a constant 1.0. Could be wrong though, and it's an easy enough thing to verify in the debugger.

TheHoosier
Dec 30, 2004

The fuck, Graham?!

Metos posted:

Yeah first step I'd do would be to move the debug.log inside OnTouch to above the if statements.

Could also be floating point accuracy loss, where because Time.timeScale is a float its actual value might be at ~.99995 instead of 1 and so is not equal to 1 when you check. The easy version is to check if its >.9 or <.1 instead of == 1 and == 0.

Ok, i'll try that. Thanks everyone. UIManager is a GameObject storing that script, with the different functions assigned to On Click () for each respective button. I thought maybe it was a canvas or Z-position issue but it hasn't made a different.

Also, is it possible this is an issue?

quote:

void Update() {

bool pressedFireButton = Input.GetButtonDown("Fire1");
if (pressedFireButton)
{
Rigidbody2D rigidbody = GetComponent<Rigidbody2D>();
rigidbody.velocity = Vector3.zero;
rigidbody.AddForce(Vector3.up * _upwardForceMultiplier);
}

That's the "jump" script. Could calling Fire1 be interfering with registering presses elsewhere?

Edit: Yeah debug isn't returning anything. I put it above the IF statements in the OnClick() function and it doesn't return anything in the debugger. The buttons just don't seem to be interacting whatsoever. Weird..

Edit 2: Ran an OnMouseOver() set to return to the Debug log and attached it to a few things, and something is definitely obstructing the buttons in the Scene. Everything I attached the debug script to returned a value except the buttons. I'll keep working on it..

TheHoosier fucked around with this message at 12:33 on Nov 4, 2020

Metos
Nov 25, 2005

Sup Ladies

TheHoosier posted:

Edit 2: Ran an OnMouseOver() set to return to the Debug log and attached it to a few things, and something is definitely obstructing the buttons in the Scene. Everything I attached the debug script to returned a value except the buttons. I'll keep working on it..
The problem will be with CanvasGroups, specifically the Block Raycasts field inside of them needs to be unticked on anything that shouldn't be clicked on, and interactable needs to be ticked only on things that should be clicked on, like your buttons' parent canvasgroup.

Unfortunately we can't see your hierarchy in full detail so I can't tell exactly where the problem is, but in a broad sense - go through every CanvasGroup for elements that shouldn't be clicked on (eg a Pause heading) and turn off Block Raycasts, and if you think something needs more linear control then add another CanvasGroup and set it up properly.

I know this is just an early flappy bird clone, but you may also want to look into an alternative method to turning UI objects on and off as they're required - which is to keep the UI always there but invisible and unclickable. So rather than using GameObject.SetActive(false), you can set your UI up and turn the CanvasGroup.alpha to 0, CanvasGroup.interactable to false, and CanvasGroup.blockRaycasts to false

Then when you want your UI to come up you call a Show() method which turns up its CanvasGroup.alpha to 1, CanvasGroup.interactable to true, and CanvasGroup.blockRaycasts to true.

edit - thought of a new way to help debug: moving the buttons you want to click to the top of the canvas children hierarchy will also place it in front of other objects so that it should be clicked on before objects that are potentially blocking it - you can then place other objects on top of it in the hierarchy one by one until you find what was blocking it when you suddenly can't click the button anymore.

Metos fucked around with this message at 22:27 on Nov 4, 2020

Triarii
Jun 14, 2003

If you select your EventSystem object while the game is running, it'll show you a bunch of info about what the cursor is hovering/clicking/etc. That tends to make it pretty obvious if you have something blocking your button.

TheHoosier
Dec 30, 2004

The fuck, Graham?!

Metos posted:

The problem will be with CanvasGroups, specifically the Block Raycasts field inside of them needs to be unticked on anything that shouldn't be clicked on, and interactable needs to be ticked only on things that should be clicked on, like your buttons' parent canvasgroup.

Unfortunately we can't see your hierarchy in full detail so I can't tell exactly where the problem is, but in a broad sense - go through every CanvasGroup for elements that shouldn't be clicked on (eg a Pause heading) and turn off Block Raycasts, and if you think something needs more linear control then add another CanvasGroup and set it up properly.

I know this is just an early flappy bird clone, but you may also want to look into an alternative method to turning UI objects on and off as they're required - which is to keep the UI always there but invisible and unclickable. So rather than using GameObject.SetActive(false), you can set your UI up and turn the CanvasGroup.alpha to 0, CanvasGroup.interactable to false, and CanvasGroup.blockRaycasts to false

Then when you want your UI to come up you call a Show() method which turns up its CanvasGroup.alpha to 1, CanvasGroup.interactable to true, and CanvasGroup.blockRaycasts to true.

edit - thought of a new way to help debug: moving the buttons you want to click to the top of the canvas children hierarchy will also place it in front of other objects so that it should be clicked on before objects that are potentially blocking it - you can then place other objects on top of it in the hierarchy one by one until you find what was blocking it when you suddenly can't click the button anymore.

You guys are saints, thanks for entertaining my dumb questions. I did figure it out: The canvas containing the buttons was missing the Standalone Input Module component. Everything works now! I will definitely try out the different method for turning UI elements on/off.

I'll probably call it now that i've got the buttons working, and maybe try another project. I've looked up some tutorial projects and will probably choose something other than a flappy bird clone so I can get more experience with coding.

Adbot
ADBOT LOVES YOU

ddiddles
Oct 21, 2008

Roses are red, violets are blue, I'm a schizophrenic and so am I
Is there any different between the new user experience with UE4 and Unity?

I've had this vague notion that it would be fun to hack on a simple game for a couple years, but every time I start up a unity project, I get the point where I'm building something thats more complex than moving an object around, and I just cant seem to find any guidance on how to do it. Any tutorial is the equivalent of a hello world website. For example, last time I gave up because even creating a simple UI was pretty daunting for a new user.

I fully accept I'm a lazy piece of poo poo who could just read the Unity docs, but I need to be visually hand held through things or it just doesnt stick. Is it any better in UE4? I picked Unity because it seemed like all the UE4 tutorials were blueprint based rather than code, and I'm not really that interested in learning that.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply