Random.Range doesn't work
Hi Guys,
So I'm currently new to Unity and programming in general, and I wanted to try making a visual memory game where you have to remember a pattern and right at the beginning I stumble to a problem i couldn't fix. so my plan was that i get a random number from the Blue Tile int and i gave each Tile a bnr (Box number) in an order which a calculator would have. And my plan was just to get 1 number and that if the Blue Tile int had the same number as one of the 9 Tiles it would be Blue
https://preview.redd.it/b5vpmihvdrzd1.png?width=2560&format=png&auto=webp&s=f022f1d05796e23c78e85af046a873a13aedeced
https://preview.redd.it/riav6olxdrzd1.png?width=2560&format=png&auto=webp&s=2ec8e345da7869601bb7d1b12d5c451bba7d4507
https://preview.redd.it/v53hws3zdrzd1.png?width=2560&format=png&auto=webp&s=8f0f47ce0236b5d4f3f583d17a8636aa5f81ce37
Now my Problem is that sometimes 2 Boxes or 3 Boxes get Blue or sometimes even noone, but I can't figure out why. Im thankful to anyone who comments under this post.
https://redd.it/1gmvqiz
@r_Unity3D
Hi Guys,
So I'm currently new to Unity and programming in general, and I wanted to try making a visual memory game where you have to remember a pattern and right at the beginning I stumble to a problem i couldn't fix. so my plan was that i get a random number from the Blue Tile int and i gave each Tile a bnr (Box number) in an order which a calculator would have. And my plan was just to get 1 number and that if the Blue Tile int had the same number as one of the 9 Tiles it would be Blue
https://preview.redd.it/b5vpmihvdrzd1.png?width=2560&format=png&auto=webp&s=f022f1d05796e23c78e85af046a873a13aedeced
https://preview.redd.it/riav6olxdrzd1.png?width=2560&format=png&auto=webp&s=2ec8e345da7869601bb7d1b12d5c451bba7d4507
https://preview.redd.it/v53hws3zdrzd1.png?width=2560&format=png&auto=webp&s=8f0f47ce0236b5d4f3f583d17a8636aa5f81ce37
Now my Problem is that sometimes 2 Boxes or 3 Boxes get Blue or sometimes even noone, but I can't figure out why. Im thankful to anyone who comments under this post.
https://redd.it/1gmvqiz
@r_Unity3D
Help for absolute beginner with C# and Unity
Hi Guys,
I'm an absolute beginner and I'm really stuck on this. I was following a tutorial to make a 2D game in Unity. I cannot make a drop down for 'Animator' appear in the noscript window in Unity (see below - highlighted in purple). Below is the code I've written. Can someone please tell me where I'm going wrong?
https://preview.redd.it/17c0yq5ywrzd1.png?width=1158&format=png&auto=webp&s=5077132966b3bd98d465c37cce505c97c423bc3a
https://preview.redd.it/mzk80m6xxrzd1.png?width=416&format=png&auto=webp&s=5137c2d1932909ae58159f15e60bc136e3881bba
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Player : MonoBehaviour
{
// Start is called before the first frame update
public float moveSpeed = 5f;
public Rigidbody2D rb;
Vector2 velocity;
public Animator animator;
}
void Start()
{
}
// Update is called once per frame
void Update()
{
velocity = Vector2.zero;
velocity.x = Input.GetAxisRaw("Horizontal");
velocity.y = Input.GetAxisRaw("Vertical");
UpdateAnimation();
}
void UpdateAnimation()
{
if (velocity != Vector2.zero)
{
animator.SetBool("Walking", true);
animator.SetFloat("Horizontal", velocity.x);
animator.SetFloat("Vertical", velocity.y);
} else
{
animator.SetBool("Walking", false);
}
}
void UpdateMovement()
{
rb.MovePosition(rb.position + velocity moveSpeed Time.fixedDeltaTime);
}
https://redd.it/1gmy6zd
@r_Unity3D
Hi Guys,
I'm an absolute beginner and I'm really stuck on this. I was following a tutorial to make a 2D game in Unity. I cannot make a drop down for 'Animator' appear in the noscript window in Unity (see below - highlighted in purple). Below is the code I've written. Can someone please tell me where I'm going wrong?
https://preview.redd.it/17c0yq5ywrzd1.png?width=1158&format=png&auto=webp&s=5077132966b3bd98d465c37cce505c97c423bc3a
https://preview.redd.it/mzk80m6xxrzd1.png?width=416&format=png&auto=webp&s=5137c2d1932909ae58159f15e60bc136e3881bba
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Player : MonoBehaviour
{
// Start is called before the first frame update
public float moveSpeed = 5f;
public Rigidbody2D rb;
Vector2 velocity;
public Animator animator;
}
void Start()
{
}
// Update is called once per frame
void Update()
{
velocity = Vector2.zero;
velocity.x = Input.GetAxisRaw("Horizontal");
velocity.y = Input.GetAxisRaw("Vertical");
UpdateAnimation();
}
void UpdateAnimation()
{
if (velocity != Vector2.zero)
{
animator.SetBool("Walking", true);
animator.SetFloat("Horizontal", velocity.x);
animator.SetFloat("Vertical", velocity.y);
} else
{
animator.SetBool("Walking", false);
}
}
void UpdateMovement()
{
rb.MovePosition(rb.position + velocity moveSpeed Time.fixedDeltaTime);
}
https://redd.it/1gmy6zd
@r_Unity3D
Apply generic border to a tiles in a tilemap for procedural generation
I am making a topdown tile based game in unity, currently I am generating a heightmap and using that heightmap I am assigning it to layers of tilemaps. Eg at height 4 I assign a dirt tile to tilemap 1, 2 and 3 and then a grass to 4.
But due to this there isnt a way to differentiate different heights so i would like to apply a generic black outline as well as a collider to all tiles based on whether or not there is a neighbouring tile on that tilemap. I had a look at unity ruletiles but from what I've read it seems that for every single new tile I add I would have to redo all the tile rules just to gain the same affect (I have also heard of the idea of overlaying another tilemap on top of the pre exsisting one with the borders added but this seems inefficent and I am already layer tilemaps). Ideally I would want all tiles to inherit a generic way of generating an outline. What would be the easiest way of going about this am i overlooking something?
https://redd.it/1gmyfci
@r_Unity3D
I am making a topdown tile based game in unity, currently I am generating a heightmap and using that heightmap I am assigning it to layers of tilemaps. Eg at height 4 I assign a dirt tile to tilemap 1, 2 and 3 and then a grass to 4.
But due to this there isnt a way to differentiate different heights so i would like to apply a generic black outline as well as a collider to all tiles based on whether or not there is a neighbouring tile on that tilemap. I had a look at unity ruletiles but from what I've read it seems that for every single new tile I add I would have to redo all the tile rules just to gain the same affect (I have also heard of the idea of overlaying another tilemap on top of the pre exsisting one with the borders added but this seems inefficent and I am already layer tilemaps). Ideally I would want all tiles to inherit a generic way of generating an outline. What would be the easiest way of going about this am i overlooking something?
https://redd.it/1gmyfci
@r_Unity3D
Reddit
From the Unity2D community on Reddit
Explore this post and more from the Unity2D community
How can I make an Animation freeze on the final frame instead of looping?
https://preview.redd.it/6ajzhnjr4tzd1.png?width=1232&format=png&auto=webp&s=353aca5845a5573844b7cba6222e90a3f99eca3d
In accordance to all of the documentation I have found, I changed the following settings to 'Clamp Forever' but that made absolutely no difference.
Additionally, I even tried having this function fire at the final frame of the animation, and it does fire as the logs show me, but again, the animation just continues to loop as normal.
// Pauses the Animator
public void FreezeAnimation(){
print("STOP ANIMATIOR");
anim.speed = 0;
}
This feels like it should be extremely simple but I've spent over 4 hours trying to get this to work
https://redd.it/1gn2jo2
@r_Unity3D
https://preview.redd.it/6ajzhnjr4tzd1.png?width=1232&format=png&auto=webp&s=353aca5845a5573844b7cba6222e90a3f99eca3d
In accordance to all of the documentation I have found, I changed the following settings to 'Clamp Forever' but that made absolutely no difference.
Additionally, I even tried having this function fire at the final frame of the animation, and it does fire as the logs show me, but again, the animation just continues to loop as normal.
// Pauses the Animator
public void FreezeAnimation(){
print("STOP ANIMATIOR");
anim.speed = 0;
}
This feels like it should be extremely simple but I've spent over 4 hours trying to get this to work
https://redd.it/1gn2jo2
@r_Unity3D
Prefab text bleeding over into another Prefab
A quick explanation of my use case. In my Unity App, I have a button that when clicked prompts the user to put in two fields of text. After that, I have a Prefab that is created to display the text.
The Prefab is an empty object, that has Four Children. (See attached Image)
The first child is a Canvas that has a Content Fitter (Vertical Fit: Preferred Size). It then has a child that has a TextMeshPro Text (Date), and another child that's a TextMeshPro Text, this is where the text the user put in is displayed, (Content Size Fitter: Preferred Size) As well there is an Image and a TextMeshProText (Title)
The second child is a Canvas that has a Content Fitter (Vertical Fit: Preferred Size). It then has a child that has a TextMeshPro Text (Title), and another TextMeshPro Text, this is where the text the user put in is displayed, (Content Size Fitter: Preferred Size) As well there is also an Image.
The third child is an Image
The fourth child is a button.
ISSUE:
The issue is the text that is being displayed is bleeding over into the next prefab created (see attached image). Does anyone know how to prevent this from happening?
https://preview.redd.it/dbk2za35otzd1.png?width=524&format=png&auto=webp&s=3d2bf5834a03670271905de443793710edc86c31
https://preview.redd.it/d5mfodc6otzd1.png?width=524&format=png&auto=webp&s=1dc30e3b6eb8407e30fd8f8f3a214da249baa8b4
https://redd.it/1gn47xs
@r_Unity3D
A quick explanation of my use case. In my Unity App, I have a button that when clicked prompts the user to put in two fields of text. After that, I have a Prefab that is created to display the text.
The Prefab is an empty object, that has Four Children. (See attached Image)
The first child is a Canvas that has a Content Fitter (Vertical Fit: Preferred Size). It then has a child that has a TextMeshPro Text (Date), and another child that's a TextMeshPro Text, this is where the text the user put in is displayed, (Content Size Fitter: Preferred Size) As well there is an Image and a TextMeshProText (Title)
The second child is a Canvas that has a Content Fitter (Vertical Fit: Preferred Size). It then has a child that has a TextMeshPro Text (Title), and another TextMeshPro Text, this is where the text the user put in is displayed, (Content Size Fitter: Preferred Size) As well there is also an Image.
The third child is an Image
The fourth child is a button.
ISSUE:
The issue is the text that is being displayed is bleeding over into the next prefab created (see attached image). Does anyone know how to prevent this from happening?
https://preview.redd.it/dbk2za35otzd1.png?width=524&format=png&auto=webp&s=3d2bf5834a03670271905de443793710edc86c31
https://preview.redd.it/d5mfodc6otzd1.png?width=524&format=png&auto=webp&s=1dc30e3b6eb8407e30fd8f8f3a214da249baa8b4
https://redd.it/1gn47xs
@r_Unity3D
We’re working hard on Whirlight - No Time To Trip, our new point-and-click adventure. Here’s a sneak peek of one of the new locations. But behind all this work is a passion we've had since childhood. Here are a few games from our collection that inspired us to create Whirlight.
https://redd.it/1gn4t0n
@r_Unity3D
https://redd.it/1gn4t0n
@r_Unity3D
Reddit
From the Unity2D community on Reddit: We’re working hard on Whirlight - No Time To Trip, our new point-and-click adventure. Here’s…
Explore this post and more from the Unity2D community
Creating an item having AoE with pools as molotov
In my game, I try to make an incendiary bomb that creates a burning ground to defined blast radius after exploding. My game's 16 x 16 pixel per tile so I prepare a fire animation sprites first by 16 x 16 then made the sprite mode to "Tiled" so that fire AoE can change if some item is pick-up or something.
Then at the same game object I have a simple animator that plays this 4 frame burning animation. In default, this animation plays a 16x16 fire animation.
So I have two issues there. First one is that, I want animator to play more fire tiles as defined at below code in Start() with tweaking spriteRenderer.size. (This sprite's draw mode is "Tiled" so fire sprite can repeat according to the size). I want animator to play the same AoE with spriteRenderer's size. That's the first issue.
Second one, if first one is solved, fiery area will be a square shaped burning ground. Instead of square, I want to eliminate corners and edges outside of circleOrigin shown in Editor. I tried to use masks but I couldn't make it maybe the root reason is still the animator or something else. I put related code below. Thanks for your support in advance.
https://preview.redd.it/byapcfoytuzd1.png?width=867&format=png&auto=webp&s=d08f447fc4949a50acb31cbaf1232045bf4b3f83
https://redd.it/1gn7fr7
@r_Unity3D
In my game, I try to make an incendiary bomb that creates a burning ground to defined blast radius after exploding. My game's 16 x 16 pixel per tile so I prepare a fire animation sprites first by 16 x 16 then made the sprite mode to "Tiled" so that fire AoE can change if some item is pick-up or something.
Then at the same game object I have a simple animator that plays this 4 frame burning animation. In default, this animation plays a 16x16 fire animation.
So I have two issues there. First one is that, I want animator to play more fire tiles as defined at below code in Start() with tweaking spriteRenderer.size. (This sprite's draw mode is "Tiled" so fire sprite can repeat according to the size). I want animator to play the same AoE with spriteRenderer's size. That's the first issue.
Second one, if first one is solved, fiery area will be a square shaped burning ground. Instead of square, I want to eliminate corners and edges outside of circleOrigin shown in Editor. I tried to use masks but I couldn't make it maybe the root reason is still the animator or something else. I put related code below. Thanks for your support in advance.
https://preview.redd.it/byapcfoytuzd1.png?width=867&format=png&auto=webp&s=d08f447fc4949a50acb31cbaf1232045bf4b3f83
https://redd.it/1gn7fr7
@r_Unity3D
This media is not supported in your browser
VIEW IN TELEGRAM
Breaking the fourth wall. A character in the game just ate one of the textures.
https://redd.it/1gn8qt1
@r_Unity3D
https://redd.it/1gn8qt1
@r_Unity3D
Since the beginning, I've struggled to find an easy-to-read and visually appealing HUD for enemies stats in Sliding Hero. Looking for feedback to help me finally take a definitive stance.
https://redd.it/1gnaqqj
@r_Unity3D
https://redd.it/1gnaqqj
@r_Unity3D
Found Some High-Quality Free AI SoundFX!
They’re comparable to paid sites and even allow commercial use without any issues!
Perfect for game devs, video editors, podcasters, or anyone needing sound effects. They’ve got everything from ambient sounds to effects that are pro-level mixed—super helpful for any creative project. If you’re on the hunt for free SoundFX, definitely check these out!
https://redd.it/1gnb2ni
@r_Unity3D
They’re comparable to paid sites and even allow commercial use without any issues!
Perfect for game devs, video editors, podcasters, or anyone needing sound effects. They’ve got everything from ambient sounds to effects that are pro-level mixed—super helpful for any creative project. If you’re on the hunt for free SoundFX, definitely check these out!
https://redd.it/1gnb2ni
@r_Unity3D
Reddit
From the Unity2D community on Reddit
Explore this post and more from the Unity2D community
Is this over optimizing? Connecting particle systems to large trigger colliders
https://i.imgur.com/8nONyvx.mp4
https://redd.it/1gncnt9
@r_Unity3D
https://i.imgur.com/8nONyvx.mp4
https://redd.it/1gncnt9
@r_Unity3D
Imgur
Discover the magic of the internet at Imgur, a community powered entertainment destination. Lift your spirits with funny jokes, trending memes, entertaining gifs, inspiring stories, viral videos, and so much more from users.
My First Game is on sale now. I was fiddling around with Unity quite some time and result came. I present you When She's Gone. Historical game for anyone interested.
https://preview.redd.it/ehnvkxhzowzd1.png?width=1920&format=png&auto=webp&s=457917e3095d4df9d29060b11da9d89865548253
https://redd.it/1gnefnx
@r_Unity3D
https://preview.redd.it/ehnvkxhzowzd1.png?width=1920&format=png&auto=webp&s=457917e3095d4df9d29060b11da9d89865548253
https://redd.it/1gnefnx
@r_Unity3D
Media is too big
VIEW IN TELEGRAM
Custom 'volumetric' PS1/retro spotlights and crunchy shadows in URP.
https://redd.it/1gna1gf
@r_Unity3D
https://redd.it/1gna1gf
@r_Unity3D